What are data type in C?
How many data types are in C?
int Data Type
Integer types can be signed (with negative values) or unsigned values (only positive). Int values are always signed unless specifically mentioned.
example :-
int number = 456;
long prime = 12230234029;
Float
The floating point data type allows the user to type decimal values. For example, average marks can be 97.665. if we use int data type, it will strip off the decimal part and print only 97. To print the exact value, we need ‘float’ data type.
example:-
float average = 97.665;
float mark = 67;
printf("average is %f", average);
printf(" mark is %f", mark);
char
char stores a single character. Char consists of a single byte.
example:-
char group = ‘B’;
To print a name or a full string, we need to define char array.
char group = 'B';
char name[30] = "Student1";
printf("group is %c, name is %s", group, name);
No comments:
Post a Comment