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

while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above

738


Explain what is output redirection?

666


What is a pointer in c plus plus?

696


What do you mean by command line argument?

644


What are the rules for identifiers in c?

585






Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)

807


Which programming language is best for getting job 2020?

605


What is use of pointer?

587


What are the disadvantages of a shell structure?

690


Can you explain the four storage classes in C?

642


What are the advantages of c language?

666


What does 3 periods mean in texting?

600


How can I read in an object file and jump to locations in it?

577


What are the advantages of the functions?

604


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

569