Program that structure to specify data of customers in a bank
Object: Create a structure to specify data of customers in a bank. The data to be stored is: Account number, Name, Balance in account. Assume a maximum of 200 customers in the bank. Write a function to print the Account number and name of each customer with a balance below Rs. 1000. C++ projects for beginners with source code
Code:
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
void custs();
struct bank
{
string name;
int id;
float baln;
char nam[20];
}c[4];
void main()
{
int i;
for(i=0;i<4;i++)
{
cout<<“Enter “<<i+1<<” Customer details\n”;
cout<<“Enter First Customer Name: “;
cin>>c[i].nam;
cout<<“Enter Account Number: “;
cin>>c[i].id;
cout<<“Enter Balance in Account: “;
cin>>c[i].baln;
cout<<“\n”;
}
custs();
getch();
}
void custs()
{
int i;
cout<<“:customer Details:\n”;
for(i=0;i<4;i++)
{
if(c[i].baln<1000)
{
cout<<“Customer Name is: “<<c[i].nam<<endl;
cout<<“Customer Account No. id: “<<c[i].id<<endl;
cout<<“Customer Balance is: “<<c[i].baln;
cout<<endl;
}
}
cout<<endl;
}
#include<iostream> #include<conio.h> #include<string> using namespace std; void custs(); struct bank { string name; int id; float baln; char nam[20]; }c[4]; void main() { int i; for(i=0;i<4;i++) { cout<<"Enter "<<i+1<<" Customer details\n"; cout<<"Enter First Customer Name: "; cin>>c[i].nam; cout<<"Enter Account Number: "; cin>>c[i].id; cout<<"Enter Balance in Account: "; cin>>c[i].baln; cout<<"\n"; } custs(); getch(); } void custs() { int i; cout<<":customer Details:\n"; for(i=0;i<4;i++) { if(c[i].baln<1000) { cout<<"Customer Name is: "<<c[i].nam<<endl; cout<<"Customer Account No. id: "<<c[i].id<<endl; cout<<"Customer Balance is: "<<c[i].baln; cout<<endl; } } cout<<endl; }
Output:
Pingback: C++ projects for beginners with source code - Codeboks
Great post, I think blog owners should learn a lot from this site it’s real user pleasant.