Question

In: Computer Science

C Program Write a program to read an equation a/b*x^c*fun(alpha)+d/e*x^f*fun(beta)+g where: a-f are integers alpha,beta are...

C Program

Write a program to read an equation

a/b*x^c*fun(alpha)+d/e*x^f*fun(beta)+g

where:

a-f are integers

alpha,beta are angles from 0,360

g is a real number(float)

fun is either sin, cos, or tangent

After reading the equation, and its parameters, ask the user to enter a range for x, and evaluate the given function.

Display a table x, fx with 10 spaces each, and 5 digits of precision.

Solutions

Expert Solution

code:

//declare stdio and math header
//for input output and power functions usage.
#include <stdio.h>
#include<math.h>
int main()
{
//declare required variables.
int a,b,c,d,e,f,alpha,beta,x;
float g;
//read user input.
printf("Enter a,b,c,d,e,f,alpha and beta values:\n");
scanf("%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&alpha,&beta);
//read x range.
printf("Enter range of x: ");
scanf("%d",&x);
//display table along with functon values.
printf("x\t|\tfx\n------------------------\n");
for(int i=0;i<x;i++)
{
printf("%d\t|\t",i);
printf("%.5f\n",(a/b*pow(i,c)*sin(alpha)+d/e*pow(i,f)*sin(beta)+g));
}
return 0;
}

-----------------------------------------------------

output:

Enter a,b,c,d,e,f,alpha and beta values:                                                                                

10 5 3 8 4 3                                                                                                            

60 90                                                                                                                   

Enter range of x: 5                                                                                                     

x       |       fx                                                                                                      

------------------------                                                                                                

0       |       0.00000                                                                                                 

1       |       1.17837                                                                                                 

2       |       9.42698                                                                                                 

3       |       31.81605                                                                                                

4       |       75.41581

----------------------------

kindly comment for queries if any, upvote if you like it.

Thankyou.


Related Solutions

Write a C program to read an equation. a/b*x^c*fun(alpha)+d/e*x^f*fun(beta)+g a-f are integers, alpha and beta are...
Write a C program to read an equation. a/b*x^c*fun(alpha)+d/e*x^f*fun(beta)+g a-f are integers, alpha and beta are angle from 0-360. g is real number(float). function is either sin, cos or tan. After reading the equation, and its parameters, ask the user to enter an range for x, and evaluate the given function. Display a table x, fx with 10 spaces each, and 5 digits of precision. Can use only pow, and the sin,cos, and tan function in math.h. Cannot use C-...
If there are 7 total notes C, D, E, F, G, A, and B and if...
If there are 7 total notes C, D, E, F, G, A, and B and if a five-note melody is selected at random (so that all melodies counted in part (a) are equally likely to be chosen), what is the probability that the melody will include exactly two “A” notes, but no other repeated notes? (A few allowable examples: AACEG, ACAEG, DFACA, EAABC, etc.)
Consider the cross: A/a; b/b; C/c; D/d; E/e x A/a; B/b; c/c; D/d; e/e a) what...
Consider the cross: A/a; b/b; C/c; D/d; E/e x A/a; B/b; c/c; D/d; e/e a) what proportion of the progeny will phenotypically resemble the first parent? b) what proportion of the progeny will genotypically resemble neither parent?
A. Beta emission is associated with: (SELECT ALL THAT APPLY) a, b, c, d, e, f,...
A. Beta emission is associated with: (SELECT ALL THAT APPLY) a, b, c, d, e, f, g B. Electron-capture is associated with: (ALL THAT APPLY) a, b, c, d, e, f, g C. Alpha emission is associated with (ALL THAT APPLY) a, b, c, d, e, f, g D. Positron emission is associated with (SELECT ALL THAT APPLY) a, b, c, d, e, f, g a. increase in mass number b. emission of a photon c. decrease in mass number...
Seven people (A,B,C,D,E, F, and G) are seated in a row. Suppose A,B, and C are...
Seven people (A,B,C,D,E, F, and G) are seated in a row. Suppose A,B, and C are freshmen, D and E are sophomores and F and G are juniors. How many arrangements are possible if: (a) D and F must sit together? (b) A and C must not sit together? (c) All freshmen must sit together? (d) All freshmen must sit together, all sophomores must sit together, and all juniors must sit together? (e) Exactly two people sit between A and...
(a) (f ∘ g)(3) (b) g(f(2)) (c) g(f(5)) (d) (f ∘ g)(−3) (e) (g ∘ f)(−1) (f) f(g(−1))
(a)    (f ∘ g)(3) (b)    g(f(2)) (c)    g(f(5)) (d)    (f ∘ g)(−3) (e)    (g ∘ f)(−1) (f)    f(g(−1))  
A restaurant has dishes A, B, C, D, E, F and G The owners anticipate that...
A restaurant has dishes A, B, C, D, E, F and G The owners anticipate that dishes will be ordered in the following proportions: 30% (A), 15% (B), 20% (C), 5% (D), 8% (E), 12% (F) and 10% (G). The number of orders placed during the first two days of business was 75 (A), 60 (B), 50 (C), 14 (D), 20 (E), 40 (F), and 41 (G).    State and conduct the appropriate hypothesis test to determine whether there is...
Consider the relation R= {A, B, C, D, E, F, G, H} and the set of...
Consider the relation R= {A, B, C, D, E, F, G, H} and the set of functional dependencies: FD= {{B}—> {A}, {G}—> {D, H}, {C, H}—> {E}, {B, D}—> {F}, {D}—>{C}, {C}—> {G}} 1) Draw FD using the diagrammatic notation. 2) What are all candidate keys for R? 3) If delete {C}—>{G} and change {C, H}—> {E} to {C, H}—> {E, G}, what are all candidate keys for R
The curves of the quadratic and cubic functions are f(x)=2x-x^2 and g(x)= ax^3 +bx^2+cx+d. where a,b,c,d...
The curves of the quadratic and cubic functions are f(x)=2x-x^2 and g(x)= ax^3 +bx^2+cx+d. where a,b,c,d ER, intersect at 2 points P and Q. These points are also two points of tangency for the two tangent lines drawn from point A(2,9) upon the parobala. The graph of the cubic function has a y-intercept at (0,-1) and an x intercept at (-4,0). What is the standard equation of the tangent line AP.
The curves of the quadratic and cubic functions are f(x)=2x-x^2 and g(x)= ax^3 +bx^2+cx+d. where a,b,c,d...
The curves of the quadratic and cubic functions are f(x)=2x-x^2 and g(x)= ax^3 +bx^2+cx+d. where a,b,c,d ER, intersect at 2 points P and Q. These points are also two points of tangency for the two tangent lines drawn from point A(2,9) upon the parobala. The graph of the cubic function has a y-intercept at (0,-1) and an x intercept at (-4,0). What is the value of the coefficient "b" in the equation of the given cubic function.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT