Write a program which will calculate the value of x using the following options
x=p(1+k)^r
where k =30% of p
Enter the value of p and r from the user
I wrote this:
{
float x;
float p,k,r;
cout<<"Please enter the value of P";
cin>>p;
k=(p/100)*30;
cout<<"k";
cout<<k;
cout<<"Please enter the value of r";
cin>>r;
x={p(1+k)^r};
cout<<"x";
cin>>x;
return 0;
}
it giving the error that P cannot use as a function…
Can anyone please help
I’ve edited your post for readability. When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.
Not sure what are those brackets in"x={p(1+k)^r};" for but i’m gonna guess that you want to assign p * (1 + k) ^ r to the x variable.
If yes than add the missing multiplication symbol and use pow function instead of “^”. http://www.cplusplus.com/reference/cmath/pow/