Tuesday, November 2, 2021

 What are data type in C?

Data types in c refer to an extensive system used for declaring variables or functions of different types. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted.


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

Wireless Security Configuration: Protect Your Network Now!

Introduction: In today’s connected world, wireless networks are as common as smartphones, and they’re often the gateway to our personal, pr...