C++ program that stores the information of 50 clients.Details include customer name, code, date of starting, number of years, interest rate, and total amount.A program to calculate compound interest for these clients.

Our program will have a structure ‘ClientData’ that stores the information :

i)customer name
ii)Date of starting
iii)Number of years
iv)interest rate and
v)total amount.(Principal)

For our program we will assume that the compound interest is calculated yearly.So in applying the formula

Amount * (1+ rate/n)nt

The amount obtained is ‘Principal+compound interest’ ,so subtracting principal from the calculated amount will give the compound interest.

The structure with the clients detail as it’s data members is shown below.

struct ClientData
string name ;
unsigned code ;
double date_of_starting ,
year ,
rate ,
amount ,
compound_interest ;

/*This function calculate the total amount “principal + compound interest”*/
double total_amount();

double clientData::total_amount( )
return ( amt*( pow(1+ rate/year , year)) );

The t=1,since the interest is calculated yearly.And the “pow(1+rate/year , year)” calculate the value of (1+rate/year)year.This function is included in the cmath header.

Link: C++ cmath pow function

The code written inside main function is shown below.

const unsigned n=2; //number of clients,change it according to your needs

ClientData data[n];

int main( )
cout<<“Enter the client detail\n” ;
for(int i=0; i<n; i++)
cout<<“Name:” ;
getline(cin , data[i].name); //getline gets the name and store it in the name data member
cout<<“Code:” ;
cin>> data[i].code ;
cout<< “Date of starting:” ;
cin>> data[i].date_of_starting ;
cout<<“Year:” ;
cin>> data[i].year ;
cout<<“Rate:” ;
cin>> data[i].rate ;
cout<<“Amount:” ;
cin>> data[i].amount ;
cin.ignore() ;

cout<< “\n\n” ;

/*Computing compound interest */
data[i].compound_interest= data[i].total_amount()- data[i].amount ;

/*Printing out the client data */
for(int i=0 ; i<n ; i++ )
cout<< “Name:” << data[i].name ;
cout<< “\nCode:” << data[i].code ;
cout<< “\nDate of starting:” << data[i].date_of_starting ;
cout<< “\nYear:” << data[i].year ;
cout<< “\nRate:” << data[i].rate ;
cout<< “\nAmount:” << data[i].amount ;
cout<< “\nCompound interest:” << data[i].compound_interest << endl << endl ;

cin.get( ) ;
return 0 ;

You can download the complete source code here.

More C++ programs

C++ program to add , subtract , multiply and divide two complex numbers.

A C++ program to find month,date and day after 50 days from the current date.


Stop wasting time,earn money($$$) from your website-Join Now!