Find the size of various types of datatypes in c programming language

C Programming Language / Operators and Enums in C Language

899

Program:

// sizeof operator in c programming language
// find the size of various types of datatypes

#include<stdio.h>
void main(){

printf("size of int: %d byte\n",sizeof(int));
printf("size of character: %d byte\n", sizeof(char));
printf("size of float: %d byte\n", sizeof(float));
printf("size of double: %d byte\n", sizeof(double));
printf("size of long double: %d byte\n", sizeof(long double));


printf("size of signed: %d byte\n", sizeof(signed int));
printf("size of unsigned int: %d byte\n", sizeof(unsigned int));

printf("size of short int: %d byte\n", sizeof(short int));
printf("size of long int: %d byte\n", sizeof(long int));

printf("size of signed short int: %d byte\n", sizeof(signed short int));
printf("size of unsigned short int: %d byte\n", sizeof(unsigned short int));

printf("size of signed long: %d byte\n", sizeof(signed long int));
printf("size of unsigned long int: %d byte\n", sizeof(unsigned long int));  

}

Output:

size of int: 4 byte
size of character: 1 byte
size of float: 4 byte
size of double: 8 byte
size of long double: 12 byte
size of signed: 4 byte
size of unsigned int: 4 byte
size of short int: 2 byte
size of long int: 4 byte
size of signed short int: 2 byte
size of unsigned short int: 2 byte
size of signed long: 4 byte
size of unsigned long int: 4 byte
Press any key to continue . . .

Explanation:

sizeof operator in c programming language

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.