Program the following. Implement the following equation 3x4 sin(180x) + 4x3 cos(90x) + x2 sin(tan(45)) + 7x + 9cos(90x2 ) where x may be user defined value.
#include <stdio.h>
#include <math.h>
#ifndef M_PI
#define M_PI (3.14159265358979323846)
#endif
#define X (1)
int main() {
// 3x4 sin(180x)
float res = 3.f * X * 4.f * sin(M_PI * X);
// + 4x3 cos(90x)
res += 3.f * X * 4.f * cos(X * M_PI / 2.f);
// + x2 sin(tan(45))
res += X * 2.f * sin(tan(M_PI / 4.f));
// + 7x
res += 7.f * X;
// + 9cos(90x2 )
res += 9.f * cos(X * 2.f * M_PI / 2.f);
printf("Result: %f\n", res);
return 0;
}
Comments
Leave a comment