Data Types in C Programming Language

C Programming: Data Types

Each variable in C has an associated data type. Each data type requires different amounts of memory and has some specific operations which can be performed over it. Let us briefly describe them one by one:

Following are the examples of some very common data types used in C:

  • char: The most basic data type in C. It stores a single character and requires a single byte of memory in almost all compilers.
  • int: As the name suggests, an int variable is used to store an integer.
  • float: It is used to store decimal numbers (numbers with floating point value) with single precision.
  • double: It is used to store decimal numbers (numbers with floating point value) with double precision

Different data types also have different ranges upto which they can store numbers. These ranges may vary from compiler to compiler. Below is list of ranges along with the memory requirement and format specifiers on 32 bit gcc compiler.

Data TypesMemory(in bytes)Range Format specifier
 Short int
 
2-32,768 to 32,767%hd
unsigned short int20 to 65,535%hu
unsigned int40 to 4,294,967,295%u
int4-2,147,483,648 to 2,147,483,647 %d
long int 4-2,147,483,648 to 2,147,483,647 %Id
unsigned long int40 to 4,294,967,295%Iu
long long int8-(2^63) to (2^63)-1 %Iid
unsigned ling long int80 to 18,446,744,073,709,551,615 
 
%IIu
signed char1-128 to 127%c
unsigned char10 to 255%c
float4%f
long8%if
We will be happy to hear your thoughts

Leave a reply

Edusera
Logo
Open chat
1
Scan the code
Hello!๐Ÿ‘‹
Can we help you?