image.png

  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4. cout << "Size of char : " << sizeof(char) << endl;
  5. cout << "Size of int : " << sizeof(int) << endl;
  6. cout << "Size of short int : " << sizeof(short int) << endl;
  7. cout << "Size of long int : " << sizeof(long int) << endl;
  8. cout << "Size of float : " << sizeof(float) << endl;
  9. cout << "Size of double : " << sizeof(double) << endl;
  10. cout << "Size of wchar_t : " << sizeof(wchar_t) << endl;
  11. return 0;
  12. }
  13. /*
  14. Size of char : 1
  15. Size of int : 4
  16. Size of short int : 2
  17. Size of long int : 4
  18. Size of float : 4
  19. Size of double : 8
  20. Size of wchar_t : 4
  21. */

Reference

https://www.tutorialspoint.com/cplusplus/cpp_data_types.htm