by Dinesh Thakur Category: C Programming (Pratical)

This is C program that asks user to define the size of data types acquired by them. Data types are known as those elements that tells the user which kind of data elements they have for example integer type for numeric value, char type for characters. All the data types have their limits for numerical expressions like char is 0-255 bits.

In this program user to define the size of data types. User declares a variable int i for storing or contain the value that will be imprinted as result on the screen. All the data types are printed through the print method. User also declares a method to fetch out the size of data types.
Problem Statement:
This is C program example to fetch out the size of data types.

  1. Declare variable.
  2. Define method to fetch out data type size.
  3. Display result on the screen.

Here is C source code for fetching out the data types size. Output of this program shown below. 

#include <stdio.h>
void main()
  int i;
  printf("    short int is %2d bytes \n", sizeof(short int));
  printf("          int is %2d bytes \n", sizeof(int));
  printf("        int * is %2d bytes \n", sizeof(int *));
  printf("     long int is %2d bytes \n", sizeof(long int));
  printf("   long int * is %2d bytes \n", sizeof(long int *));
  printf("   signed int is %2d bytes \n", sizeof(signed int));
  printf(" unsigned int is %2d bytes \n", sizeof(unsigned int));
  printf("        float is %2d bytes \n", sizeof(float));
  printf("      float * is %2d bytes \n", sizeof(float *));
  printf("       double is %2d bytes \n", sizeof(double));
  printf("     double * is %2d bytes \n", sizeof(double *));
  printf("  long double is %2d bytes \n", sizeof(long double));
  printf("  signed char is %2d bytes \n", sizeof(signed char));
  printf("         char is %2d bytes \n", sizeof(char));
  printf("       char * is %2d bytes \n", sizeof(char *));
  printf("unsigned char is %2d bytes \n", sizeof(unsigned char));

Find Out the Size of the Different Data Types

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.