fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int SIZE;
  6.  
  7. cout << "Enter the size of an array\n";
  8. cin >> SIZE;
  9.  
  10. int array[SIZE];
  11.  
  12. for (int i = 0 ; i < SIZE ; i ++)
  13. {
  14. array[i] = i*i;
  15. }
  16.  
  17. for (int i = 0 ; i < SIZE ; i ++)
  18. {
  19. cout << array[i] << endl;
  20. }
  21.  
  22. // Array as pointer
  23. cout << "&SIZE address " << &SIZE << endl;
  24. cout << "Address of first element " << array << endl;
  25. cout << "Address of last element " << (array + SIZE - 1 ) << endl;
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5264KB
stdin
2
stdout
Enter the size of an array
0
1
&SIZE address 0x7fffabe85eb4
Address of first element 0x7fffabe85e90
Address of last element 0x7fffabe85e94