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
Is it possible to pass an entire structure to functions?
Explain bitwise shift operators?
How are portions of a program disabled in demo versions?
What is the purpose of realloc()?
What are the benefits of c language?
#include
List the difference between a While & Do While loops?
Explain spaghetti programming?
What was noalias and what ever happened to it?
What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
Explain the process of converting a Tree into a Binary Tree.
Explain how can I remove the trailing spaces from a string?
What is const and volatile in c?
Can we assign string to char pointer?
What is the heap in c?