Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert C to C++

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I need help with my code in C to be coverted to C++.Please help me.Vianca

# include <stdio.h>
# include <math.h>
# include <stdlib.h>


int main (void)
{

float pricipal,rate,payment;
int term;
char ch;

while (1)
{

puts(&quot;Enter The Loan Amount:&quot;);
scanf(&quot;%f&quot;,&principal);
puts(&quot;\nEnter The Annual Interest Rate:&quot;);
scanf(&quot;%f&quot;,&rate);

rate /=100;

rate /=12;

puts(&quot;Enter the Loan Duration in Months:&quot;);
scanf(&quot;%d&quot;,&term);
payment = (principal * rate) / (1 - pow((1 + rate),- term));
printf(&quot;Your monthly Payment will be $%2f.\n&quot;,payment);

puts(&quot;Do Another(y or n)?&quot;);
do
{
ch = getchar();
} while (ch != 'n' && ch != 'y');

if (ch == 'n')

break;

}
return(0);
}
 
There you go.

#include <iostream.h>
#include <math.h>
#include <stdlib.h>
int main ()
{

float principal,rate,payment;
int term;
char ch;

while (1)
{

cout<<&quot;Enter The Loan Amount:&quot;;
cin>>principal;
cout<<&quot;\nEnter The Annual Interest Rate:&quot;;
cin>>rate;

rate /=100;

rate /=12;

cout<<&quot;Enter the Loan Duration in Months:&quot;;
cin>>term;
payment = (principal * rate) / (1 - pow((1 + rate),- term));
cout<<&quot;Your monthly Payment will be&quot;<<payment<<endl;

cout<<&quot;Do Another(y or n)?&quot;;
do
{
cin>>ch;
} while (ch != 'n' && ch != 'y');

if (ch == 'n')

break;

}
return(0);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top