5: Program to check size of data types
#include<iostream>
using namespace std;
main(){
int a;
cout<<"The size of int is " <<sizeof(a)<<endl;
float b;
cout<<"The size of float is " <<sizeof(b)<<endl;
char c;
cout<<"The size of char is " <<sizeof(c)<<endl;
double d;
cout<<"The size of double is " <<sizeof(d)<<endl;
bool e;
cout<<"The size of bool is " <<sizeof(e)<<endl;
return 0;
}
Output:
The size of int is 4
The size of float is 4
The size of char is 1
The size of double is 8
The size of bool is 1
Thus:
The size of int is 4 byte
The size of float is 4 byte
The size of char is 1 byte
The size of double is 8 byte
The size of bool is 1 byte
Comments
Post a Comment