I can find records of account holders whom data are stored in a structure. I have used the array of structure data type. But when the record is not found in the array of structure data type, it should display the message "Record not Found" only once.
Below is my program and please correct it as per the requirement mentioned above.
#include<iostream.h>
#include<stdlib.h>
int main()
{
int choice,accNo,i,j=0,k=0,l=0,m=0,found;
char accName[20],accType[10];
struct Account
{
int acc_No;
char name[20];
char type[10];
int balance;
};
Account acc[3];
for(i=0;i<3;i++)
{
cout<<"Please enter the Account No.: ";
cin>>acc[i].acc_No;
cout<<"Please enter the Account Holder Name: ";
cin>>acc[i].name;
cout<<"Please enter the Account type: ";
cin>>acc[i].type;
cout<<"Please enter the Account Balance: ";
cin>>acc[i].balance;
cout<<endl<<endl;
}
do
{
cout<<"Enter 1 to search account information by Account number:"<<endl;
cout<<"Enter 2 to search account information by Account holder name:"<<endl;
cout<<"Enter 3 to search number of user having particular Account type:"<<endl;
cout<<"Enter 4 to search number of user having Account balance greater than 10,000:"<<endl;
cout<<"Enter 5 to quit from program:"<<endl;
cin>>choice;
cout<<endl<<endl;
if(choice==1)
{
cout<<"Please enter the Account No to find: ";
cin>>accNo;
for(j=0;j<3;j++)
{
if(acc[j].acc_No==accNo)
{
found=1;
cout<<endl;
cout<<"Account NO."<<acc[j].acc_No<<endl;
cout<<"Account Holder Name:"<<acc[j].name<<endl;
cout<<"Account Type:"<<acc[j].type<<endl;
cout<<"Balance:"<<acc[j].balance<<endl;
cout<<endl;
}
}
}
else if(choice==2)
{
cout<<"Please enter the Account Name to find: ";
cin>>accName;
for(k=0;k<3;k++)