using namespace std;
#include <iostream>
#define _USE_MATH_DEF
#include <conio.h>
#include <cmath>
int main()
{
const double e = 2.71;
double x, a, b, c, A, B, C, M;
cout << "Enter the value of x, a, b and c: ";
cin >> x >> a >> b >> c;
A = x pow(sqrt(x a), 3);
// cout << A;
B = x - sqrt((abs(x - b)));
// cout << B;
C = A / B;
M = pow(e, -1 * c) * C;
cout << "The result of function is " << M;
_getch();
return 0;
}
For example, lets define x=1, a=4, b=5, c=1.
Calculator returns M as -0.9547605358, but code calculates M
as -4.49459
.
This is mathematical formula that I need to code:
CodePudding user response:
Here I see some problems, namely A
must be
A = x pow(sqrt(x a), 1.0/3.0);
B
and C
definition is correct, but M
must be
M = pow(e, -1 * c * x) * C;
I would also like to point out that conio.h
is a non standard header file and _getch()
is non standard.