Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Ryan Nesbitt
- cis 125
- array program
- */
- #include <iostream>
- #include <string>
- using namespace std;
- void printArray(int[10]);
- void userEnterArrayTwo(int[10]);
- bool checkUserEntry(int);
- int main()
- {
- //Variable Declaration Block
- int numArrayTwo[10];
- int numArrayThree[10];
- userEnterArrayTwo(numArrayThree);
- printArray(numArrayTwo);
- printArray(numArrayThree);
- system("pause");
- return 0;
- }
- void printArray(int numArray[10])
- {
- for (int i = 0; i < 10; i++)
- {
- cout << numArray[i] << " ";
- }
- cout << endl;
- }
- void userEnterArrayTwo(int numArray[10])
- {
- int userEntry = 0;
- int itr = 0;
- bool entryGood = false;
- while (itr < 10)
- {
- cout << "Enter a number greater than -100 and less than 1000: ";
- cin >> userEntry;
- entryGood = checkUserEntry(userEntry);
- if (entryGood)
- {
- cout << userEntry << " Entry valid!" << endl;
- numArray[itr] = userEntry;
- itr++;
- }
- else
- {
- cout << "Bad entry! Please try again!" << endl;
- }
- }
- cout << "Here is your Array " << endl;
- }
- //checks user entry for the corect values
- bool checkUserEntry(int entry)
- {
- if (entry <= 1000)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement