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

Explain what is the benefit of using an enum rather than a #define constant?

1015


What is the purpose of main( ) in c language?

922


Write a program to swap two numbers without using a temporary variable?

887


What are the output(s) for the following ? #include char *f() {char *s=malloc(8); strcpy(s,"goodbye")} main() { char *f(); printf("%c",*f()='A'); }

960


How will you declare an array of three function pointers where each function receives two ints and returns a float?

1105


Explain the advantages of using macro in c language?

791


What is a program flowchart?

859


What is the condition that is applied with ?: Operator?

910


What will the code below print when it is executed?   int x = 3, y = 4;         if (x = 4)                 y = 5;         else                 y = 2;         printf ("x=%d, y=%d ",x,y);

1613


What is the meaning of && in c?

786


What is the process to generate random numbers in c programming language?

919


What are the advantages and disadvantages of pointers?

841


What is array of pointers to string?

831


Can the size of an array be declared at runtime?

846


Tell me when would you use a pointer to a function?

845