fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5.  
  6. int *dynArray; // pointer to the dynamically allocated array
  7. int size; // array size
  8.  
  9. cout << "Enter number of integers: ";
  10. cin >> size;
  11. dynArray = new int [size];
  12.  
  13. cout << "Enter integers: ";
  14. for(int i = 0; i < size; i++)
  15. cin >> dynArray[i];
  16.  
  17. cout << "You Entered: ";
  18. for(int i = 0; i < size; i++)
  19. {
  20. cout << dynArray[i] << " ";
  21. }
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 2988KB
stdin
5
1 3 5 7 9
stdout
Enter number of integers: Enter integers: You Entered: 1 3 5 7 9