PLAY WITH CODING

Home Basic Program If & Else Loops Conversion Pattern logo

Basic C Program

Program to find size of int, float, char and double

Input - Output

Output
Size of int data type = 2 bytes

Size of float data type = 4 bytes

Size of char data type = 1 byte

Size of double data type = 8 bytes

Algorithm

Step 1: START

Step 2: Declare a variable as an Integer ,Float,Character and Double.

Step 4: Print result

Step 5: END

CODE


/* find size of int , float ,char , double */

#include<stdio.h>
int main()
{
      int a;
      float b;
      char c;
      double d;
      printf("size of int data_type = %d ",sizeof(a));
      printf("\nsize of float data_type = %d ",sizeof(b));
      printf("\nsize of char data_type = %d ",sizeof(c));
      printf("\nsize of double data_type = %d ",sizeof(d));
    return 0;
}


/* size of int , float ,char , double */

#include<iostream>
using namespace std;
int main()
{
      int a;
      float b;
      char c;
      double d;
      cout<<"size of int data_type = "<<sizeof(a)<<"\n";
      cout<<"size of float data_type = "<<sizeof(b)<<"\n";
      cout<<"size of char data_type = "<<sizeof(c)<<"\n";
      cout<<"size of double data_type = "<<sizeof(d)<<"\n";
    return 0;
}

OutPut

Size of int data type = 2 bytes
Size of float data type = 4 bytes
Size of char data type = 1 byte
Size of double data type = 8 bytes