Question:
Input three integers a, b, and c. Calculate and output Result using the following formula:
Result= √(b^|a+c| )/2ab
Note: | | is the operator for the absolute value.
Correct code:
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int a, b, c;
double result;
cout<<"Enter a, b and c: ";
cin>>a>>b>>c;
result = sqrt(pow(b, fabs(a + c)))/(2*a*b);
cout<<"Result "<<result<<endl;
return 0;
}
Last edited on
Is the square root supposed to be used on the whole expression or only on the numerator?