Advertisement
TermSpar

Dynamic Array

Jul 8th, 2016
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.  
  8.     int size;
  9.     cout << "Enter array size: ";
  10.     cin >> size;
  11.  
  12.     int *myRay = new int[size];
  13.  
  14.     for (int i = 0; i < size; i++) {
  15.         int newInt;
  16.         cout << "Enter number " << i + 1 << ": ";
  17.         cin >> newInt;
  18.         myRay[i] = newInt;
  19.     }
  20.  
  21.     for (int i = 0; i < size; i++) {
  22.         cout << myRay[i] << endl;
  23.     }
  24.  
  25.     delete[] myRay;
  26.  
  27.     system("pause");
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement