1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
abruzzese [7]
3 years ago
11

Please create C program, the task is to implement a function edoublepowerx that has an input parameter x of floating-point value

(real numbers), and then return the approximation of e^2x as computed using the formula e^2x = 1 + 2x / 1! + 4x^2 / 2! + 8x^3 / 3! + ... + 1024x^10 / 10! . Use this function in a C main program that asks users for the x value, perform the calculation, and output the result. To assist the implementation, you may use the recursive function fact(n) and power(x,n).
Computers and Technology
1 answer:
sp2606 [1]3 years ago
5 0

Answer:

// here is code in C.

#include <stdio.h>

// function that calculate factorial of a number recursively

long int fact_num(int num)

{

if (num >= 1)

return num*fact_num(num-1);

else

return 1;

}

// function that calculate power of a number recursively

int num_pow(int b, int p)

{

if (p != 0)

return (b*num_pow(b, p-1));

else

return 1;

}

//edoublepowerx function

float edoublepowerx(int x){

int i;

float tot_sum = 1.0;

for(i = 0; i <= 10;i++ ){

tot_sum = tot_sum + (num_pow(2,i)*num_pow(x,i))/fact_num(i);

}

return tot_sum;

}

// driver function

void main()

{

   // variables

float x,res;

printf("Please enter the value of x : ");

//read the value of x

scanf("%f",&x);

// call the function to calculate the value

res = edoublepowerx(x);

// print the result

printf("e^2x = %f",res);

}

Explanation:

In the main function, first read the value of "x" from user.Then call the function edoublepowerx() with parameter "x".In this function, total of the equation is  calculated by summing all the term one by one with the help of for loop. In the for loop,"(num_pow(2,i)*num_pow(x,i))/fact_num(i)" for each value of "i". here num_pow(), calculate the power of number recursively and fact_num() calculated the factorial of a numbers recursively.After the loop ends edoublepowerx() will return the value to the equation.

Output:

Please enter the value of x : 3                                                                                            

e^2x = 383.000000                                                                                                          

You might be interested in
How do you tack pictures for this app
olga2289 [7]
There is a paper clip on the bottom left on your screen. When answering a question click it to apply a picture. Have a wonderful day.

(Take*)
3 0
3 years ago
What is the best anime that you like the most (give me 3 plz)
Dmitry [639]

Answer:

The rising of shied hero, last hope, and dragon pilot.

4 0
3 years ago
Read 2 more answers
………………….. is the process of causing a system variable to conform to some desired value. Options Control feedback Design none of
frutty [35]
Control <span>is the process of causing a system variable to conform to some desired value. Options Control feedback Design none of the above</span>
4 0
2 years ago
A job placement agency helps match job seekers with potential employers. The agency would like to design a simulation in order t
storchak [24]

Answer:C

Explanation:

The answer is C

6 0
2 years ago
What are the steps to add a bibliography to a document? 1. Create a using the proper steps. 2. Go to the tab on the ribbon. 3. I
olasank [31]

Answer:

The steps required to add a bibliography after adding the sources of the information contained in the document and marking the references made in the text, are;

1. Click to select insertion point of the bibliography

2. Select the Reference tab by clicking on the Reference tab in the ribbon

3. Within the Citations & Bibliography group, select Bibliography to open  a dropdown list of bibliography format

4. Select the applicable format

5. By selecting the desired bibliography format, the bibliography is inserted at the selected insertion point of the document

Explanation:

6 0
3 years ago
Other questions:
  • What would I need to make the perfect music video
    10·1 answer
  • Utilities software and word processing software are both eamples of
    10·1 answer
  • What is Least effective at preventing a computer virus
    10·1 answer
  • hona is buying a rug for her room. Store A has the rug for $45 with a 10% discount. Store B has the same rug for $46 and is offe
    5·1 answer
  • Which key must you press after you write into a cell?
    12·1 answer
  • What is it called when you make a reference in the text of a document alerting the reader that you are using information from an
    10·1 answer
  • EX 3.8 Write code to declare and instantiate an object of the Random class (call the object reference variable rand). Then write
    6·1 answer
  • PLEASE HELP! I'm offering brainliest!
    6·1 answer
  • You designed a program to create a username using the first three letters from the first name and the first four letters of the
    6·1 answer
  • Edhesive 2.3 code practice question 1​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!