Wednesday, December 11, 2013

Please,give one or two programmes using do...while loop in c++?

Here is a program on interest calculation
using do while
loop



#include<iostream.h>


#include<conio.h>


float
cal (float amt, int year, float rate=15);


void prn (char
c='*');


void main
()


{


clrscr();


float
amount, interest;


int
year;


cout<<"Enter the amount on which
interest has to be calculated:
-";


cin>>amount;


cout<<"Enter
the number of years:
-";


cin>>year;


interest=cal
(amount, year);


prn
();


cout<<"The interest
on-"<<amount<<"-for the period
of-"<<year<<" years would
be"<<interest<<endl;


prn
('-');


getch
();


}


float cal (float amt,
int year, float rate)


{


int
i;


float
sum=amt;


i=1;


do


{


sum=sum
* (1+
(rate/100));


i++;


}while(i<=year);


return
sum-amt;


}


void prn (char
c)


{


for (int i=0;
i<40;
i++)


{


cout<<c;


}


cout<<endl;


}

No comments:

Post a Comment

How is Anne&#39;s goal of wanting &quot;to go on living even after my death&quot; fulfilled in Anne Frank: The Diary of a Young Girl?I didn&#39;t get how it was...

I think you are right! I don't believe that many of the Jews who were herded into the concentration camps actually understood the eno...