29/01/2023

Write a C Program to Display The Size of Different Data Types

Write a c program to display the size of different data types. Here is one thing noted down the size of Datatype maybe depends upon your Operating System. Operating System You Are using maybe 32 Bit or 64 Bit. The data type of problems can handle easily in C++. C++ have a "sizeof" Operator to find the size of any datatype following the given syntax. The size of data types in c can be solved by using the following syntax.

Syntax: sizeof( datatype )

Write a C Program to Display The Size of Different Data Types

See Also: C++ Program to Display The Size of Different Data Types

C Program to Display The Size of Different Data Types


#include <stdio.h>

int main() {
  printf("Size of Int Data Types in C = %2d bytes \n", sizeof(short int));
  printf("Size of Long Int Data Types in C = %2d bytes \n", sizeof(long int));
  printf("Size of Float Data Types in C = %2d bytes \n", sizeof(float));
  printf("Size of Double Data Types in C = %2d bytes \n", sizeof(double));
  printf("Size of Long Double Data Types in C = %2d bytes \n", sizeof(long double));
  printf("Size of Char Data Types in C = %2d bytes \n", sizeof(char));
  return 0;
}

See Also: Java Program to Display The Size of Different Data Types

The Output of Print Size of Data Types in C


The Output of Print Size of Data Types in C

List of Size of Data Types in C


Below is the list of the Data Types in C or The size of data types in c. C Programming Data Type, Range and Size in Bytes.

  1. Int
  2. Long Int
  3. Float
  4. Char
  5. Double
  6. Long Double

TypeRangeSize (in bytes)
Unsigned Char0 to 2551
Signed Char or Char-128 to +1271
Unsigned Int0 to 655352
Signed Int or Int-32,768 to +327672
Unsigned Short Int0 to 655352
Signed Short Int or Short Int-32,768 to +327672
Unsigned Long Int0 to +4,294,967,2954
Signed Long Int or Long Int-2,147,483,648 to +2,147,483,6474
Long Double3.4E-4932 to 1.1E+493210
Double1.7E-308 to 1.7E+3088
Float3.4E-38 to 3.4E+384
Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me

0 Comments: