Respuesta :
Answer:
#include <iostream>
using namespace std;
int main(){
int accountnum;
[tex]int\ accountnumbers[18] = \{5658845, 4520125, 7895122, 8777541,[/tex] [tex]8451277, 1302850, 8080152,4562555, 5552012, 5050552, 7825877,[/tex] [tex]1250255, 1005231, 6545231,3852085, 7576651, 7881200, 4581002\};[/tex]
cout<<"Account Number: ";
cin>>accountnum;
int arrlength =*(&accountnumbers + 1) - accountnumbers;
int exist = 0;
for(int i =0;i<arrlength;i++){
if(accountnum == accountnumbers[i]){
cout<<"Valid account number";
exist = 1;
break;
}
}
if(exist == 0)
cout<<"Invalid account number";
return 0;
}
Explanation:
The solution is implemented in C++ (See attachment)
This declares user account number as integer
int accountnum;
This initializes the list of account numbers to an array
[tex]int\ accountnumbers[18] = \{5658845, 4520125, 7895122, 8777541,[/tex] [tex]8451277, 1302850, 8080152,4562555, 5552012, 5050552, 7825877,[/tex] [tex]1250255, 1005231, 6545231,3852085, 7576651, 7881200, 4581002\};[/tex]
This prompt user for account number
cout<<"Account Number: ";
Here, user inputs the account number
cin>>accountnum;
This calculates the length of the array
int arrlength =*(&accountnumbers + 1) - accountnumbers;
This initializes a check variable to 0
int exist = 0;
This iterates through the array
for(int i =0;i<arrlength;i++){
This checks for valid account number.
if(accountnum == accountnumbers[i]){
If true, the following message is printed
cout<<"Valid account number";
The check variable is updated to 1, which implies that the account number is valid
exist = 1;
And the loop is terminated
break;
}
}
If the check variable is not updated, then the account number is invalid
if(exist == 0)
cout<<"Invalid account number";
return 0;