Sinux1

PS7Q2.cpp

Apr 14th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int inputx;
  8.  
  9.  
  10.     cout << "How many integers do you have? (Max 20)\n";
  11.     cin >> inputx;
  12.  
  13.     if(!(inputx < 1) && !(inputx > 20))
  14.     {
  15.         int num_array[inputx];
  16.  
  17.         for(int x = 0; x < inputx; x++)
  18.         {
  19.             cout << "Enter element for subscript " << x << endl;
  20.             cin >> num_array[x];
  21.         }
  22.  
  23.         cout << "Here are all of those numbers\n";
  24.  
  25.         for (int x = 0; x< inputx; x++)
  26.         cout << num_array[x] << endl;
  27.     }
  28.     else
  29.     {
  30.         cout << "You must enter a number in between 1 and 20\n";
  31.          exit(0);
  32.     }
  33.     return 0;
  34. }
Add Comment
Please, Sign In to add comment