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

Where we use clrscr in c?

693


What does the file stdio.h contain?

597


Can we access the array using a pointer in c language?

554


List some of the static data structures in C?

755


How many identifiers are there in c?

571






Explain 'bus error'?

546


Differentiate between static and dynamic modeling.

608


What does stand for?

582


Can you write the function prototype, definition and mention the other requirements.

650


What is the meaning of ?

602


What does the characters “r” and “w” mean when writing programs that will make use of files?

846


Differentiate between a structure and a union.

756


What is action and transformation in spark?

585


Is null always defined as 0(zero)?

602


What is the use of in c?

567