Write a C++ program that displays the sizes of different data types.

 


#include<iostream>

using namespace std;

int main()

{

cout<<"Size of char = "<<sizeof(char)<<endl;

cout<<"Size of int = "<<sizeof(int)<<endl;

cout<<"Size of float = "<<sizeof(float)<<endl;

cout<<"Size of long = "<<sizeof(long)<<endl;

cout<<"Size of double = "<<sizeof(double)<<endl;

cout<<"Size of long double = "<<sizeof(long double)<<endl;

}

OUTPUT

Size of char = 1

Size of int = 4

Size of float = 4

Size of long = 4

Size of double = 8

Size of long double = 16

1 comment: