There are some predefined keywords in C - Language that defines what kind of data would be stored in a variable, what operations can be applied on this data, how much memory will be occupied, and what will be the value range +ve and -ve to store in variable.
Common Data types in C - Language.
There are three main data types
- Integral
- Floating Point
- Character
- int
- long
- float
- double
- char
- signed
- unsigned
When we use "unsigned" keyword with data type it blocks the input of -ve numbers and doubles the value range for this variable.
When we use "singed" or don't use this, -ve and +ve both type of values can be stored in the variable.
Integral Data Types in C.
Type | Storage size | Value range |
---|---|---|
char | 1 byte | -128 to 127 or 0 to 255 |
unsigned char | 1 byte | 0 to 255 |
signed char | 1 byte | -128 to 127 |
int | 2 bytes | -32,768 to 32,767 |
unsigned int | 2 bytes | 0 to 65,535 |
short | 2 bytes | -32,768 to 32,767 |
unsigned short | 2 bytes | 0 to 65,535 |
long | 4 bytes | -2,147,483,648 to 2,147,483,647 |
unsigned long | 4 bytes | 0 to 4,294,967,295 |
#include <stdio.h> #include <conio.h> int main() { printf("Storage size for int : %d \n", sizeof(int)); return 0; }Here above is a code snippet to check the actual size of any Data type, use have to replace required data type with (int).
Note: in char type we can store any one character using single quots around it.
Floating Point Data Types
Type | Storage size | Value range | Precision |
---|---|---|---|
float | 4 byte | 1.2E-38 to 3.4E+38 | 6 decimal places |
double | 8 byte | 2.3E-308 to 1.7E+308 | 15 decimal places |
long double | 10 byte | 3.4E-4932 to 1.1E+4932 | 19 decimal places |
nice sir
ReplyDeleteGreat work sir
ReplyDelete