Write a simple program to find the size of different basic
data types in C.

Answer Posted / gajendra patil

#include <stdio.h>
#include <conio.h>

int main(){

int *a;
printf("\nSIZE OF DIFFERENT DATA TYPES\n");
printf("\n------------------------------");
printf("\n\tBASIC");
printf("\n------------------------------");
printf("\nCHARACTER \t: %d byte(s)",sizeof(char));
printf("\nSHORT \t\t: %d byte(s)",sizeof(short));
printf("\nINTEGER \t: %d byte(s)",sizeof(int));
printf("\nLONG \t\t: %d byte(s)",sizeof(long));
printf("\nFLOAT \t\t: %d byte(s)",sizeof(float));
printf("\nDOUBLE \t\t: %d byte(s)",sizeof(double));
printf("\nLONG DOUBLE \t: %d byte(s)",sizeof(long double));
printf("\nLONG LONG \t: %d byte(s)",sizeof(long long));
printf("\nPOINTER (any) \t: %d byte(s)",sizeof(*a));
printf("\nARRAY \t\t: sizeOfDataType * sizeOfArray [eg. int a[10]=%d byte(s)]",sizeof(int)*10);
printf("\n------------------------------");

return 0;
}

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.

1980


What is the use of bitwise operator?

888


What is calloc() function?

870


What is realloc in c?

827


Are pointers integers in c?

829


Write a program to check palindrome number in c programming?

792


Can stdout be forced to print somewhere other than the screen?

861


Place the #include statement must be written in the program?

775


Why is structure padding done in c?

897


Explain how can you tell whether two strings are the same?

819


Write a program to print factorial of given number using recursion?

800


define string ?

872


Can a variable be both constant and volatile?

833


Is calloc better than malloc?

792


why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above

853