C program to find the size of int, float, double and char
Given four types of variables, namely int, char, float and double. The task is to write a program to find the size of these four types of variables in C.

Examples:
Input: int Output: Size of int = 4 Input: double Output: Size of double = 8
In the below program, to find the size of the four variables, first the four types of variables are defined in
,
,
and
. Then, the size of the variables are calculated using sizeof() operator.
Below is the C program to find the size of int, char, float and double datatypes:
// C program to find the size of int, char, // float and double datatypes #include <stdio.h> int main() { int integerType; char charType; float floatType; double doubleType; // Calculate and Print the size of integerType printf("Size of int is: %ld\n", integerType); // Calculate and Print the size of charType printf("Size of char is: %ld\n", charType); // Calculate and Print the size of floatType printf("Size of floatType is: %ld\n", floatType); // Calculate and Print the size of doubleType printf("Size of double is: %ld\n", doubleType); return 0; } |
Output:
Size of int is: 4 Size of char is: 1 Size of floatType is: 4 Size of double is: 8
Recommended Posts:
- Difference between float and double in C/C++
- Modulus of two float or double numbers
- What is the difference between single quoted and double quoted declaration of char array?
- C Program to find size of a File
- C program to print a string without any quote (singe or double) in the program
- Lex Program to accept a valid integer and float value
- Python 3 | Program to print double sided stair-case pattern
- What's difference between char s[] and char *s in C?
- What is the difference between "char a" and "char a[1]"?
- C Program for Maximum size square sub-matrix with all 1s
- C / C++ Program for Median of two sorted arrays of same size
- Program that receives a number and prints it out in large size
- How to find size of array in C/C++ without using sizeof ?
- Difference between const char *p, char * const p and const char * const p
- Comparison of a float with a value in C
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



