by Dinesh Thakur Category: Array Pointer and Union

 

#include<iostream.h>

#include<conio.h>
void main()
{
            struct customer
         {
                  char name[20];
                  char address[30];
                  int phone_no;
                     struct account
                 {
                    char b_name[20];
                    int account_no;
                    float balance;
                 } acc[50];
         } cust[10];
                                    int i,j,n,m;
                                    clrscr();
                                    cout<<"\n How Many Customer in the Bank : ";
                        cin>> n;
                        cout<<"\n How Many Account Number in the Branch :";
                        cin>> m;
                        cout<<"\n Enter the Customer Data:";
                        for(i=1;i<=n;i++)
                            {
                                        cout<<"\n Enter Customer Name, Address and Phone No :";
                                        cin>> cust[i].name>> cust[i].address>>cust[i].phone_no;
                                        cout<<"\n Enter the Bank Branch Data :";
                                        for(j=1;j<=m;j++)
                                           {
                                               cout<<"\n Enter Branch Name, Account Number and Balance:";
                                               cin>> cust[i].acc[j] .b_name>> cust[ i].acc[j].account_no >>cust[i] .acc[j].balance;
                                           }
                            }
                                               cout<<"\n Customer Data is As: ";
                                               for(i=1;i<=n;i++)
                                                   {
                                                      cout<<"\n Customer Name is: "<< cust[i].name;
                                                      cout<<"\n Customer Address is : "<< cust[i].address;
                                                      cout<<"\n Customer Phone No is: "<< cust[i].phone_no ;
                                                      cout<<"\n The Bank Branch Data is:";
                                                      for(j=1;j<=m;j++)
                                                          {
                                                              cout<<"\n Branch Name is :"<< cust[i].acc[j].b_name;
                                                              cout<<"\n Account Number is : "<< cust[i].acc[j].account_no;
                                                              cout<<"\n Balance is : "<< cust[i].acc[j].balance;
                                                          }
                                                  }
                                                               getch();
}

Handle Bank Customer Data By Using Nesting Of Structure



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles