Program to Find the Size of int - (C Programs)
Example
#include <stdio.h>
int main() {
int n;
printf("Size of Integer: %d bytes", sizeof(n));
return 0;
}
Output
Size of Integer: 4 bytes
Explanation
The sizeof
operator in C language is used to determine the size of a variable or data type. In the above program, we have declared an integer variable n
and used the sizeof
operator to get the size of the integer data type. The size of int
data type in C language is 4 bytes. Therefore, the output of the program is Size of Integer: 4 bytes
.
Use
This program is useful when we need to determine the size of int
data type in a C program. The output of this program can be used by other programs that need to allocate memory for integer variables.
Summary
In this C program, we have used the sizeof
operator to determine the size of int
data type. The size of int
data type in C language is 4 bytes. This program is useful for determining the size of int
data type in C programs.