Program to find Size of all Data Types in C++
Notes:
C++ Program to print Size of all Data Types:
#include <iostream>
using namespace std;
int main()
{
cout << "size of char = " << sizeof(char) << " byte" << endl; // 1
cout << "size of signed char = " << sizeof(signed char) << " byte" << endl; // 1
cout << "size of unsigned char = " << sizeof(unsigned char) << " byte" << endl; // 1
cout << "size of int = " << sizeof(int) << " bytes" << endl; // 4
cout << "size of signed int = " << sizeof(signed int) << " bytes" << endl; // 4
cout << "size of unsigned int = " << sizeof(unsigned int) << " bytes" << endl; // 4
cout << "size of short int = " << sizeof(short int) << " bytes" << endl; // 2
cout << "size of signed short int = " << sizeof(signed short int) << " bytes" << endl; //2
cout << "size of unsigned short int = " << sizeof(unsigned short int) << " bytes" << endl; //2
cout << "size of long int = " << sizeof(long int) << " bytes" << endl; // 4
cout << "size of signed long int = " << sizeof(signed long int) << " bytes" << endl; //4
cout << "size of unsigned long int = " << sizeof(unsigned long int) << " bytes" << endl; //4
cout << "size of float = " << sizeof(float) << " bytes" << endl; // 4
cout << "size of double = " << sizeof(double) << " bytes" << endl; // 8
cout << "size of long double = " << sizeof(long double) << " bytes" << endl; // 12
cout << "size of wchar_t = " << sizeof(wchar_t) << " bytes" << endl; // 2
cout << "size of bool = " << sizeof(bool) << " byte" << endl; // 1
cout << "size of void = " << sizeof(void) << " byte" << endl; // 1
return 0;
}