• Techiax

Tutorial - C Datatypes

Data types represent different types (character, number, fraction, etc) of values that can be stored within a variable.

Also Read: Tutorial - C programming - Decision Statements


data_type variable_name;


Modifiers can be used with the basic data types to change the range of values that the data type can hold

  • short
  • long
  • unsigned
  • signed

Basic Data types:

  • int
  • float
  • double
  • char

Integer Datatype:


Size: 2 bytes
Range: -32,768 to 32,767
Format specifier: %d

unsigned int:

Size: 2 bytes
Range: 0 to 65,535
Format specifier: %d

long int:

Size: 4 bytes
Range: -2,147,483,648 to 2,147,483,647
Format specifier: %ld

long long int:

Size: 8 bytes
Range: -2^63 to 2^63-1

Float Datatype:


Size: 4 bytes
Range: 1.23E-38 to 3.42E+38
Precision: Single point precision - 6 decimal places
Format Specifier: %f

Double Datatype:


Size: 8 bytes
Range: 2.32E-308 to 1.71E+308
Precision: Double point precision - 15 decimal places
Format Specifier: %lf

You could also add modifiers like used in int.

Character Datatype:

Format Specifier: %c
char is used to character values like alphabets and special character.
They are converted to ASCII values and stored like 'a' is equal to ASCII value 97



 int main() {
    int a=12345;
    long int b=87654321;
    float c=321.123;
    double d=321.123456;
    char e='a';
    printf("int value %d \n",a);
    printf("long int value %ld \n",b);
    printf("float value %f \n",c);
    printf("double value %lf \n",d);
    printf("char value %c and ASCII is %d \n",e,e);
    return 0;


 int value 12345
 long int value 87654321
 float value 321.123
 double value 321.123456
 char value a and ASCII is 97

Output may vary based on the compiler and software you use.

Use with different modifiers and learn more about datatypes.

Also Read: Check your heart beat rate with Android

Please share your views and thoughts. It will help us do more.


I am an enthusiastic person striving to gather as much information as possible to achieve higher heights and to share the information to all others to make them also reach the stars.
"People who are crazy enough to think they can change the world are the ones who do"
-Steve Jobs.

Previous Post
Next Post