I’ve no idea what your teacher asked you, but it could be a bit more complicated than what you tried so far.
create a function for data input |
Doesn’t it mean you should ask the user some input?
If so, which input? ‘x’? ‘m’?
Also: (always if so) is the user expected to provide the values in degrees or in radiants?
At first sight, it seems the steps are:
- get ‘x’ (from user?)
- get ‘m’ (from user?)
- do you already know what ‘d’ and ‘C’ are?
- reckon ‘z’
- output the result (‘z’)
If so, maybe you need a bunch of functions like:
double getXAsDegreesFromUser();
double fromDegreesToRadians(double degrees);
// double fromRadiansToDegrees(double radians); ?
double calcZ(double x, double d, double C, double m);
...
So that main() would look like:
1 2 3 4 5 6 7 8 9
|
int main()
{
double x { getXAsDegreesFromUser() };
x = fromDegreesToRadians(x);
double m { getMfromUser() };
...
std::cout << calcZ(x, d, C, m) << '\n';
}
|