fork download
  1. #include <iostream>
  2.  
  3. int main() {
  4. int a[9];
  5.  
  6. std::cout << "Memory taken up by a: " << sizeof(a) << '\n' ;
  7. std::cout << "Memory required for a 10-element array: " ;
  8. std::cout << 10 * sizeof(int) << '\n';
  9.  
  10. std::cout << "# of elements: " << sizeof(a) / sizeof(a[0]) << '\n';
  11. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
Memory taken up by a: 36
Memory required for a 10-element array: 40
# of elements: 9