Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. /*
  2. Ryan Nesbitt
  3. cis 125
  4. array program
  5. */
  6.  
  7. #include <iostream>
  8. #include <string>
  9.  
  10. using namespace std;
  11.  
  12. void printArray(int[10]);
  13. void userEnterArrayTwo(int[10]);
  14. bool checkUserEntry(int);
  15.  
  16. int main()
  17. {
  18.  
  19.     //Variable Declaration Block
  20.  
  21.     int numArrayTwo[10];
  22.     int numArrayThree[10];
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.    
  30.  
  31.  
  32.     userEnterArrayTwo(numArrayThree);
  33.  
  34.     printArray(numArrayTwo);
  35.  
  36.     printArray(numArrayThree);
  37.  
  38.     system("pause");
  39.  
  40.     return 0;
  41. }
  42.  
  43.  
  44.  
  45. void printArray(int numArray[10])
  46.  
  47. {
  48.     for (int i = 0; i < 10; i++)
  49.     {
  50.         cout << numArray[i] << " ";
  51.     }
  52.  
  53.     cout << endl;
  54. }
  55.  
  56.  
  57.  
  58. void userEnterArrayTwo(int numArray[10])
  59.  
  60. {
  61.     int userEntry = 0;
  62.     int itr = 0;
  63.     bool entryGood = false;
  64.  
  65.     while (itr < 10)
  66.     {
  67.         cout << "Enter a number greater than -100 and less than 1000:  ";
  68.         cin >> userEntry;
  69.  
  70.         entryGood = checkUserEntry(userEntry);
  71.  
  72.         if (entryGood)
  73.         {
  74.             cout << userEntry << " Entry valid!" << endl;
  75.             numArray[itr] = userEntry;
  76.             itr++;
  77.         }
  78.         else
  79.         {
  80.             cout << "Bad entry!  Please try again!" << endl;
  81.         }
  82.     }
  83.  
  84.     cout << "Here is your Array " << endl;
  85.  
  86. }
  87.  
  88. //checks user entry for the corect values
  89. bool checkUserEntry(int entry)
  90.  
  91. {
  92.     if (entry <= 1000)
  93.     {
  94.         return true;
  95.     }
  96.     else
  97.     {
  98.         return false;
  99.     }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement