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
In addition, the ^ operator does not do what you think it does. This is the bitwise exclusive-or function, not a power function. You need the pow() function from <cmath>.
Also, you want to use "(" and ")" instead of "{" and "}" in this context. And you might not need them at all when you use the pow() function.