Professional Documents
Culture Documents
Basic Data Types in C
Basic Data Types in C
PRESENTED BY
RAKSHANA M
20080UEL07
III BE ECE
1
Click to edit Master title style
CONTENTS
• C Programming
• B a s i c D a t a Ty p e s
• Primary
• Derived
• User Defined
2 2
Click
C to edit Master title style
PROGRAMMING
3
Click to
BASIC edit TYPES
DATA MasterIN
title
C style
4
Click to edit Master title style
PRIMARY
5
Click to Data
Integer edit Master
Types title style
• The integer data type in C is used to store the whole numbers without decimal values.
• Size of the int data type determined by using the size of operator in C.
• Unsigned int data type in C is used to store the data values from zero to positive numbers but it can’t
store negative values like signed int.
• Unsigned int is larger in size than signed int and it uses “%u” as a format specifier in C programming
language.
6
Click to edit
Character Master
Data Typestitle style
7
Click to edit Master
Floating-Points Datatitle
Typesstyle
8
Click toData
Double edit Master
Types title style
• A Double data type in C is used to store decimal numbers (numbers with floating point values) with
double precision. It is used to define numeric values which hold numbers with decimal values in C.
• A precision sort of data type that is capable of holding 64 bits of decimal numbers or floating points.
Since double has more precision as compared to that float then it is much more obvious that it
occupies twice the memory as occupied by the floating-point type.
• It can easily accommodate about 16 to 17 digits after or before a decimal point.
9
Click Data
Void to edit Master title style
Types
10
Click to edit
DERIVED DATAMaster
TYPEStitle style
• These are the data-types that are derived from the primitive or built-in datatypes
• These wont create a new data types , but it adds various new fuctions
TYPES:
• Function
• Array
• Pointer
• Reference
11
Click to edit Master title style
Function
• A function is a block of code or program segment that is defined to perform a specific well-defined
task.
• A function is generally defined to save the user from writing the same lines of code again and again
for the same input.
• All the lines of code are put together inside a single function and this can be called anywhere
required. main() is a default function that is defined in every program of C++.
Syntax:
• FunctionType FunctionName(parameters)
12
Click to edit Master title style
Array
Syntax:
• DataType ArrayName[size_of_array];
13
Click to edit Master title style
Pointers
Syntax:
• datatype *var_name;
14
Click to edit Master title style
Reference
• When a variable is declared as reference, it becomes an alternative name for an existing variable.
• A variable can be declared as reference by putting ‘&’ in the declaration.
15
Click to edit Master
USER-DEFINED DATAtitle
TYPESstyle
TYPES:
• Class
• Structure
• Union
• Enumeration
• Typdef
16
Click to edit Master title style
Class
Syntax:
17
Click to edit Master title style
Structure
Syntax:
struct address {
char name[50];
char street[100];
char city[50];
char state[20];
int pin;
};
18
Click to edit Master title style
Union
19
Click to edit Master title style
Enumeration
Syntax:
enum State {Working = 1, Failed = 0};
20
Click to edit Master title style
Typdef
• Using typedef does not actually create a new data class, rather it defines a name for an existing type.
• This can increase the portability(the ability of a program to be used across different types of
machines; i.e., mini, mainframe, micro, etc; without much changes into the code)of a program as only
the typedef statements would have to be changed.
• Using typedef one can also aid in self-documenting code by allowing descriptive names for the
standard data types.
Syntax:
• typedef type name;
• where type is any C++ data type and name is the new name for this data type.
• This defines another name for the standard type of C++.
21
Click to edit Master title style
Thank You
REFERNCE LINKS
• https://www.geeksforgeeks.org/data-types-in-c/
• data types
• https://byjus.com/gate/derived-data-types-in-c/
• https://www.geeksforgeeks.org/derived-data-types-in-c/
• https://www.geeksforgeeks.org/c-data-types/
• https://www.geeksforgeeks.org/user-defined-data-types-in-c/
• https://byjus.com/gate/user-defined-data-types-in-c/#:~:text=Types
%20of%20User%2DDefined%20Data,enum
22