Write a C program to implement the following equations:
a) 2x5 - 3x4 + 5x3 - 3x2 + 7x – 9
Where x is the user defined value.
b) x3sin(tan(45)) + 4x + 7cos(90x2)
Where the value of x is a floating point number provided by the user.
#include <stdio.h>
#include <math.h>
int main()
{
double x, f;
printf("Enter double value: ");
if(scanf("%lf", &x) != 1)
{
printf("Bad input\n");
return 1;
}
f = 2*x*x*x*x*x - 3*x*x*x*x + 5*x*x*x - 3*x*x + 7*x - 9;
printf("Result #1 is: %lf\n", f);
printf("\nEnter double value: ");
if(scanf("%lf", &x) != 1)
{
printf("Bad input\n");
return 1;
}
f = x*x*x*sin(tan(45)) + 4*x + 7*cos(90*x*x);
printf("Result #2 is: %lf\n", f);
return 0;
}
Comments
Leave a comment