Skip to content

C Program to Find the Size of int, float, double and char

#include <stdio.h>

int main()
{
printf(“Size of int = %zu bytes\n”, sizeof(int));
printf(“Size of float = %zu bytes\n”, sizeof(float));
printf(“Size of double = %zu bytes\n”, sizeof(double));
printf(“Size of char = %zu byte\n”, sizeof(char));

return 0;

}

Explanation

  • sizeof(int) → Finds the memory size occupied by an int.
  • sizeof(float) → Finds the memory size occupied by a float.
  • sizeof(double) → Finds the memory size occupied by a double.
  • sizeof(char) → Finds the memory size occupied by a char.
  • sizeof() is an operator in C used to determine the size of a data type or variable in bytes.