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
What is const keyword in c?
Is flag a keyword in c?
What is the difference between strcpy() and memcpy() function in c programming?
find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2
Is there sort function in c?
How do you define CONSTANT in C?
How many main () function we can have in a project?
Is c pass by value or reference?
any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above
number of times a digit is present in a number
Why static is used in c?
What is pragma in c?
WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?
How is a structure member accessed?
What is a program flowchart and how does it help in writing a program?