fork download
  1. #include <iostream>
  2. #define tamanho 10
  3. const int elementos = 10;
  4. using namespace std;
  5.  
  6. int main() {
  7. int a = 1;
  8. char b = 'a';
  9. float c = 1.0f;
  10. double d = 2.0d;
  11. short e = 1000;
  12. long f = 100000;
  13. int *g = new int[tamanho];
  14. int h[elementos];
  15. cout << "a tem " << sizeof(a) << " bytes\n";
  16. cout << "b tem " << sizeof(b) << " bytes\n";
  17. cout << "c tem " << sizeof(c) << " bytes\n";
  18. cout << "d tem " << sizeof(d) << " bytes\n";
  19. cout << "e tem " << sizeof(e) << " bytes\n";
  20. cout << "f tem " << sizeof(f) << " bytes\n";
  21. cout << "g tem " << sizeof(g) << " bytes\n";
  22. cout << "h tem " << sizeof(h) << " bytes\n";
  23. }
  24.  
  25. //https://pt.stackoverflow.com/q/52142/101
Success #stdin #stdout 0s 4504KB
stdin
Standard input is empty
stdout
a tem 4 bytes
b tem 1 bytes
c tem 4 bytes
d tem 8 bytes
e tem 2 bytes
f tem 8 bytes
g tem 8 bytes
h tem 40 bytes