on Leave a Comment

C++ Structure Program of Bank Account System

This program stores information of Bank Account System. In this program, a structure (account) contains customer account number, name and balance. To understand the concept of structure, programming example is necessary. 

C++ Structure Program of Bank Account System

/*C++ Structure Program of Bank Account System*/
#include<stdio.h>
#include<iostream>
using namespace std;
void getdata();
void putdata();
void getdetail();
struct account
{
    int acc_no;
    char name[20];
    float bal;
}cust[5];
int main()
{
    getdata();
    putdata();
    getdetail();
    return 0;
}
void getdata()
{
    int i;
    for(i=0;i<5;i++)
    {
        cout<<endl<<endl;
        cout<<"Enter information of account holder "<<i+1;
        cout<<"\nEnter account holder name : ";
        cin.get(cust[i].name,20);
        cout<<"Enter account number : ";
        cin>>cust[i].acc_no;
        cout<<"Enter amount ";
        cin>>cust[i].bal;
        fflush(stdin);
    }
}
void putdata()
{
    int i;
    for(i=0;i<5;i++)
    {
        cout<<endl<<endl;
        cout<<"Information of account holder "<<i+1;
        cout<<"\nAccount holder name : "<<cust[i].name;
        cout<<"\nAccount number : "<<cust[i].acc_no;
        cout<<"\nBalance : "<<cust[i].bal;
    }
}

OUTPUT:

Enter information of account holder 1
Enter account holder name : Bharat Chaturvedi
Enter account number : 101
Enter amount : 1000


Enter information of account holder 2
Enter account holder name : Deepak Gupta
Enter account number : 102
Enter amount : 500


Enter information of account holder 3
Enter account holder name : Jatin Kr
Enter account number : 103
Enter amount : 1500


Enter information of account holder 4
Enter account holder name : Manish Kr
Enter account number : 104
Enter amount : 2000


Enter information of account holder 5
Enter account holder name : Arpit
Enter account number : 105
Enter amount : 200


Information of account holder 1
Account holder name : Bharat Chaturvedi
Account number : 101
Balance : 1000

Information of account holder 2
Account holder name : Deepak Gupta
Account number : 102
Balance : 500

Information of account holder 3
Account holder name : Jatin Kr
Account number : 103
Balance : 1500

Information of account holder 4
Account holder name : Manish Kr
Account number : 104
Balance : 2000

Information of account holder 5
Account holder name : Arpit
Account number : 105
Balance : 200

Here, array cust[5] can store information of five account holder. Functions (getdata) is used to store customer information and function (putdata) prints the stored information of customers.

0 comments:

Post a Comment