Cpp Program to Find Size of int, float, double and char

 

This cpp program finds the size of 6 variables of the different data types, By declaring the different data types and uses of sizeof the operator.


The syntax of finding the size of the variable:

sizeof(datatype);


code:

#include <iostream>

using namespace std;


int main()

{

cout<<" The size of char "<<sizeof(char)<<" bytes"<<endl;

cout<<" The size of int "<<sizeof(int)<<" bytes"<<endl;

cout<<" The size of float "<<sizeof(float)<<" bytes"<<endl;

cout<<" The size of double "<<sizeof(double)<<" bytes"<<endl;

cout<<" The size of short "<<sizeof(short)<<" bytes"<<endl;

cout<<" The size of boolean "<<sizeof(bool)<<" bytes"<<endl;

    return 0;

}

Output:

The size of char 1 bytes

 The size of int 4 bytes

 The size of float 4 bytes

 The size of double 8 bytes

 The size of short 2 bytes

 The size of boolean 1 bytes


Comments

Popular posts from this blog

how to cout in cpp

Flutter layout

Diferrence between flutter and react native