- Data type is a finite set of values along with set of rules for different operations.
- Data is very important in terms of programming.
- Data structure is basically how data is stored and the different operations performed on that particular data.
Example : Integer data type 5, -53 and 322 etc is integer data type and int keyword to define a integer data type in c .
Types of Data type in C
- Primary data types
- secondary data types
- user define data types
- void data types
- Primary data types : It is basically the building blocks of the data structure.
Types of Primary data types
- int (integer 5, -8)
- float (real number 32.77, -3.7)
- char (characters A , Language)
|Short int or int||2||-32768 to +32767||%d|
|Signed short int or unsigned short int or Unsigned int||2||0 to 65535||%u|
|long int or signed long int ot long||4||-2147483648 to + 2147483647||%ld|
|Unsigned long int or unsigned long||4||0 to 4294967295||%lu|
Float data type
The floating point data types consists of a subset of the real numbers.
Float are these values which have a decimal point.
Example : 5 is integer data type and 5.0 is floating point data type
|int||4||-3.4e 38 to +3.4e 38||%f|
|double||8||-1.7e 308 to +1.7e 308||%lf|
|Long double||10||-1.7e 4932 to +1.7e 4932||%Lf|
Character Data Type
The character data types are used to store the special characters and the alphabets.
|Signed char or char||1||-128 to +127||%c|
|Unsigned char||1||0 to 255||%c|
Demonstration of Primary data types:
unsigned char u;
printf(“ch=%c and its ASCII value =%d”, ch, ch);
printf(“\n u=%c and its ASCII value =%d”, u, u);
Secondary data types
User Defined Data types
Types of user Defined data types
Typedef provides us a short and meaningful way to call a data type
Now we can create object for above structure student
Struct student s;
Enumerated data type
The enum data type is used to create our own data type and give it the values.
BCA, MSC, MCA
Void data type: It is also known as empty data type it is declared where no values is returned by the function.