Follow The New Tutorial updates on WhatsApp, Telegram or YouTube.

Data Types in C Language

A data type specifies the type of data that a variable can store for example integer, floating, character, etc.

Each variable in C has an associated data type. It determines the type and size of data associated with variables. 

As the name suggests, a Datatype defines the type of data being used. Each data type requires different amounts of memory and has some specific operations which can be performed over it.

Different categories of data types in the C language

TypeExample
Basiccharacter, integer, floating-point, double. (int, char, float, double)
Derivedarray, pointer, structure, union
Enumerationenums
Bool typetrue or false
voidEmpty value (void)
Different categories of data types in the C language

Basic Data Types

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

  • char
    • It stores a single character and requires a single byte of memory in almost all compilers.
  • int
    • An int variable is used to store an integer.
    • Integers are whole numbers that can have both zero, positive and negative values but no decimal values.
    • For example, 0-510
  • float: It is used to store decimal numbers (numbers with floating point value) with single precision.
  • double: It is used to store decimal numbers with double precision. 
  • void: It means “nothing” or “no type”.
Data TypesMemory SizeRange
char1 byte−128 to 127
signed char1 byte−128 to 127
unsigned char1 byte0 to 255
short2 byte−32,768 to 32,767
signed short2 byte−32,768 to 32,767
unsigned short2 byte0 to 65,535
int2 byte−32,768 to 32,767
signed int2 byte−32,768 to 32,767
unsigned int2 byte0 to 65,535
short int2 byte−32,768 to 32,767
signed short int2 byte−32,768 to 32,767
unsigned short int2 byte0 to 65,535
long int4 byte-2,147,483,648 to 2,147,483,647
signed long int4 byte-2,147,483,648 to 2,147,483,647
unsigned long int4 byte0 to 4,294,967,295
float4 byte
double8 byte
long double10 byte
Basic Data Types

We will learn about all data types in later tutorials.

Example

#include >stdio.h>
int main() {
   // datatypes
   int a = 10;
   char b = 'S';
   float c = 2.88;
   double d = 28.888;
   printf("Integer datatype : %d\n",a);
   printf("Character datatype : %c\n",b);
   printf("Float datatype : %f\n",c);
   printf("Double Float datatype : %lf\n",d);
   return 0;
}
Data Types in C Language Example Output