Data types in C Language

Data types in C:

C has different types of data types. The data type is determines how much space is occupied by variable in the storage disk.

Mainly there are two types those are Pre- defined and User Defined.

Basic data types: These are arithmetic data types Integer, Char, float and Double.

Enumerated Type: enum is the arithmetic type used to define variables used to assign certain discrete integer values throughout the program.

Void data type: Void means no value.

Derived Data types: Derived data type means these are defined by the programmer at the time of programming based on the requirement.

Arrays, pointers, structures and union.

Data Types in C:

Data TypesSizeRange
Char1 byte−128 to 127
signed char1 byte−128 to 127
unsigned char1 byte0 to 127
Short2 byte−32,768 to 32,767
signed short2 byte−32,768 to 32,767
unsigned short2 byte0 to 32,767
Int2 byte−32,768 to 32,767
signed int2 byte−32,768 to 32,767
unsigned int2 byte0 to 32,767
short int2 byte−32,768 to 32,767
signed short int2 byte−32,768 to 32,767
unsigned short int2 byte0 to 32,767
long int4 byte
signed long int4 byte
unsigned long int4 byte
Float4 byte
Double8 byte
long double10 byte

The above shows the basic data types in c.

Note: If you want to know the exact size of the variable or a type use sizeof() operator .

Below program demonstrates how to use sizeof() operator in c and know the values of basic data types.

This is basic interview question for fresher use of sizeof() operator.

#include<stdio.h>

#include<conio.h>

void main(){

printf(“size of an integer: %d \n”,sizeof(int));

printf(“size of float: %d \n”,sizeof(float));

printf(“size of Character: %d \n”,sizeof(char));

printf(“size of double: %d \n”,sizeof(double));

getch();

}

Output is :

size of an integer:2

size of float: 4

size of Character:1

size of double: 8

Press  Alt +f9 and then Ctrl+f9 to compile and run the program.

Out put of the above program is:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top