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 with 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)))));
You’re passing just one argument to the outer
powcall. 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:
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.