C Online Compiler
Example: C program to find the size of all data types using the sizeof operator
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C program to find the size of all data types using the sizeof operator #include <stdio.h> int main() { // Calculate the size of short int data type printf("The size of short int: %ld bytes\n", sizeof(short int)); // Calculate the size of unsigned short int data type printf("The size of unsigned short int: %ld bytes\n", sizeof(unsigned short int)); // Calculate the size of unsigned int data type printf("The size of unsigned int: %ld bytes\n", sizeof(unsigned int)); // Calculate the size of int data type printf("The size of int: %ld bytes\n", sizeof(int)); // Calculate the size of long int data type printf("The size of long int: %ld bytes\n", sizeof(long int)); // Calculate the size of unsigned long int data type printf("The size of unsigned long int: %ld bytes\n", sizeof(unsigned long int)); // Calculate the size of long long int data type printf("The size of long long int: %ld bytes\n", sizeof(long long int)); // Calculate the size of unsigned long long int data type printf("The size of unsigned long long int: %ld bytes\n", sizeof(unsigned long long int)); // Calculate the size of signed char data type printf("The size of signed char: %ld byte\n", sizeof(signed char)); // Calculate the size of unsigned char data type printf("The size of unsigned char: %ld byte\n", sizeof(unsigned char)); // Calculate the size of char data type printf("The size of char: %ld byte\n", sizeof(char)); // Calculate the size of float data type printf("The size of float: %ld bytes\n", sizeof(float)); // Calculate the size of double data type printf("The size of double: %ld bytes\n", sizeof(double)); // Calculate the size of long double data type printf("The size of long double: %ld bytes\n", sizeof(long double)); return 0; }
Output
Clear
ADVERTISEMENTS