Our Recommendation for You Search your Query, You can find easily. for example search by book name or course name or any other which is related to your education

Followers

how to display data type size using c++



sizeof cplusplus

A program to display the data type size.
//By using predefined sizeof() function,
//,, 1 byte = 8 bits
#include <iostream.h>
#include <stdlib.h>
int main()
{
cout<<"The size of an int is:\t\t"<<sizeof(int)<<" bytes.\n";
cout<<"The size of a short int is:\t"<<sizeof(short)<<" bytes.\n";
cout<<"The size of a long int is:\t"<<sizeof(long)<<" bytes.\n";
cout<<"The size of a char is:\t\t"<<sizeof(char)<<" bytes.\n";
cout<<"The size of a float is:\t\t"<<sizeof(float)<<" bytes.\n";
cout<<"The size of a double is:\t"<<sizeof(double)<<" bytes.\n";
cout<<"The size of a bool is:\t\t"<<sizeof(bool)<<" bytes.\n";
system("pause");
return 0;
}
End

Our Recommend post