Coutput.bmp ( 636.03k )
Number of downloads: 18I used visual C++ and Turbo C compilersand I used the same code for both, I only converted the c++ to c but the output is different. Why does it happen? please help me, I really can't understand why..... Actually this is a conversion from java. It was successfully converted to C++ but there was an error converting it in C language. I used the code I converted in C++ so that it will be easier to convert it in C language. Then the problem occurred and I reviewed it so many times but still I can’t get the desired result. THANKS A LOT.....
UNDESIRED RESULT in TurboC
Coutput.bmp ( 636.03k )
Number of downloads: 18RIGHT RESULT in VisualC++
Year &amount deposit
1year $1365
2years $1433.25
3years $1504.91
4years $1580.16
5years $1659.17
6years $1742.12
7years $1829.23
8years $1920.69
9years $2016.73
10years $2117.56
11years $2223.44
12years $2334.61
#include <iostream.h>
#include <math.h>
main()
{
double amount=0.00, n_rate=0.00;
double n_principal=0.00, n_convert_rate=0.00;
int n_years=0, year=0;
cout<<"Enter principal amount:=>$";
cin>>n_principal;
cout<<"Enter interest rate percent:=>% ";
cin>>n_rate;
cout<<"Enter number of years:=> ";
cin>>n_years;
n_convert_rate = (0.01 * n_rate);
cout<<"\n";
cout<<"Year \t Amount on deposit \n";
for (int line=1; line<=30; line+=1)
{
cout<<"-";
}
cout<<"\n";
for (year=1; year <=n_years; year++)
{
amount=(n_principal) * pow(1.0 + n_convert_rate, year);
cout<<""<< year <<"\t" <<"$" << amount<< "\n";
}
return 0;
}
This post has been edited by mayann126: 14 Mar, 2008 - 08:37 PM