开发者

Problem with annuity program: too few arguments

I'm writing a program to work out a math equation to find annuity. the formula is as shown A = M=[(1+r)^n-1/r(1+r)^n] . The program compiler I am using is Devcpp it its worked w开发者_Python百科ith my other programs and i cannot find the error in this one. it tells me that there are too few arguments in the line with the formula.

any help is greatly appreciated :)

the code is:

double M, r, n;

cout<<"M = ";
cin>>M;

cout<<"r = ";
cin>>r;

cout<<"n = ";
cin>>n;

cout<<endl;

cout<<"A = M=[(1+r)^n-1/r(1+r)^n]";
cout<<endl<<endl;

cout<<"A = ";
cout<<(M * ( pow ((( 1 + r ), n ) - 1 )/(r * ((pow(1 + r), n)))));


cout<<(M * ( pow ((( 1 + r ), n ) - 1 )/(r * ((pow(1 + r), n)))));

You're passing just one argument to the outerpow call. Where is the second argument?

Why don't you simply it? Why did you make it so unreadable that even you cannot read and understand it properly? If you can't understand it yourself, how will others understand it?

Probably you want to do this:

double r1 = pow (1 + r,n-1 );
double r2 = pow (1 + r,n)
double A =  M * r1/ (r * r2);
cout<< A;

Based on what I could understand, I wrote this. Is it correct? Do it similarly if you wanted slightly different calculation. But must do it in simple steps. That is good for you as well as for those who will read your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜