1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
#include <iostream>
using namespace std;
// Function prototype
int search_list(int [], int, int);
//need to add a function to get data from the user
const int num_count = 18;
// main function
int main()
{
// declare variables
int tests[num_count] = {5658845, 450125, 7895122, 8777541, 8451277,
1302850, 8080152, 4562555, 5552012, 5050552, 7825877, 1250255,
1005231, 654231, 3852085, 7576651, 7881200, 4581002};
double answer;
answer = 5658845, 450125, 7895122, 8777541, 8451277,
1302850, 8080152, 4562555, 5552012, 5050552, 7825877, 1250255,
1005231, 654231, 3852085, 7576651, 7881200, 4581002;
int array_pause,
results;
results = search_list(tests, num_count, array_pause);
// ask for account number
cout<<" Enter a valid Charge Account Number "<<endl;
cin >> results;
// if/else result is/ isnot correct
if (results != answer)
{
cout << "The number entered is Invalid." << endl;
}
else (results == answer);
{
cout << "The number entered is valid." << endl;
}
system("pause");
return 0;
}
// search list function function
int search_list(int list[], int numElems, int value)
{
// declare variables
int index = 0;
int position = -1;
bool found = false;
// statement if num is found or not
while (index < numElems && !found)
{
if (list[index] == value)
{
found = true;
position = index;
}
index++;
}
return position;
}
|