Question

In: Computer Science

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- strings, strings, or any other .h header.

Cannot use arrays.

The number of rows is always 11 and shows the values of x from min to max.

Solutions

Expert Solution

1. First need to include the header files required below.

# include <stdio.h>

# include <math.h>

2. Inside main declare x as integer variable,

   using printf and scanf need to ask user to input the value for x i.e. range

    int x;
    printf("Enter an Range: ");
    scanf("%d", &x);

   above code is to ask range from user and storing value into variable x.
   int a, b, c , d, e, f;

   float g;
   ask the user to enter the values for a-f similarly as above using printf and scanf and store them in a-f integer variables.
   now coming to equation.
   we store alpha caluclation in alpha variable of type float and beta value in beta variable of type float. For that we declare alpha and beta variables as float.
   float alph, bet ; // these are the variable which store values of alpha and beta caluclations
   we have to use For loop to evaluate function.
   for For Loop declare a varible of type integer below for loop, assuming i as variable for loop variable

   int i;

   also declaring
   float alpha=0.0, beta=0.0;

   Now assign for loop condition toi <=11 and increment i by 1, below is for loop example

   for(i =1;i<=11;i++)
   {
       // now caluclating alpha,similarly beta part.
       alph = a/b*pow(x, c)*fun(alpha);
       bet = d/e*pow(x, f)*fun(beta);
       alpha = alpha+32.73;
       beta = beta+32.73
       // using another for loop with variable j for cells in a table
            for(j=1;j<=2;j++)
          {
                                   printf("%d",  x);
                                   printf("\t");  // \t prints three spaces nothing but tab.
               printf("\t");
               printf("\t");
               printf(" ");
               //after calucation of alpha and beta values, we will add that with g

               printf("%0.5f ", alph+bet+g);

               printf("\n"); // printing new line after printing fx and x values.
         }

   }

// I have no idea what fun is doing  , as it is not mentioned i am skipping that part and let me know if you have more information regarding that.

Please send your queries or request if you need help.


Related Solutions

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.
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
Please fill in the blanks (values of A, B, C, D, E, F, G, H, I...
Please fill in the blanks (values of A, B, C, D, E, F, G, H, I , J) for the following financial statements. The firm’s tax rate is 35.3%. Income Statement for Fiscal Year 2015 Sales 2,000 Cost of goods sold 1,500 Gross margin 500 Selling and general expenses 300 Operating income 200 Interest income 5 205 Interest expense 21 Restructuring charges 14 Income before tax 170 Income tax 60 Net income J Balance Sheet, Year 2014 and Year 2015...
In how many ways can 7 people { A, B, C, D, E, F, G }...
In how many ways can 7 people { A, B, C, D, E, F, G } be seated at a round table if (a) A and B must not sit next to each other; (b) C, D, and E must sit together (i.e., no other person can sit between any of these three)? (c) A and B must sit together, but neither can be seated next to C or D. Consider each of these separately. For (c) you may NOT...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT