Write C Program For sizeof operator Main
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
// sizeof operator #include <stdio.h> #include <conio.h> int main() { clrscr(); printf( "The size of an int is:\t\t" ); printf( "%d bytes.\n", sizeof(int) ); printf( "The size of a short int is:\t" ); printf( "%d bytes.\n", sizeof(short) ); printf( "The size of a long int is:\t" );; printf( "%d bytes.\n", sizeof(long) ); printf( "The size of a char is:\t\t" ); printf( "%d bytes.\n", sizeof(char) ); printf( "The size of a float is:\t\t" ); printf( "%d bytes.\n", sizeof(float) ); printf( "The size of a double is:\t" ); printf( "%d bytes.\n", sizeof(double) ); getch(); return 0; } Output: The size of an int is: 4 bytes. The size of a short int is: 2 bytes. The size of a long int is: 4 bytes. The size of a char is: 1 bytes. The size of a float is: 4 bytes. The size of a double is: 8 bytes. |
(Visited 22 times, 1 visits today)