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
Help me help you............
KiRa [710]

Answer:

change how big or small the shape or sprite is

6 0
1 year ago
Differentiate between Scope and Linkage
Lera25 [3.4K]

Answer: The difference between the scope and linkage is as follows:-

  • Scope of the variable is defined as the variable view from different program parts whereas the linkage is described as the link that is made between the variable and the declaration function having the common name.
  • Scope of variable describes about the existing time of the variable in the program whereas linkage is defined for the name of variable present in the program is available at all time .

6 0
3 years ago
Janice usually works on a particular workbook that contains all business related data. She decides to keep a backup of all the d
quester [9]

The answer is to use the Ctrl and C keys on the keyboard to copy content from one workbook to another.

The Ctrl and C key is the standard combination keys on the keyboard that is used to copy any selected text or objects while in a user interface environment. Janice is required to press the C key while holding down the Ctrl key to copy all the content to the new workbook.

Another way of doing it is to make sure that both source and target workbooks are open. Navigate the sheets you want to copy or move in the source workbook. Click the Home tab and select then format dropdown in the Cells group. Select move or copy sheet option in the Organize sheet option. Choose the target workbook from the To Book dropdown and click OK.

6 0
3 years ago
Read 2 more answers
How to hard reset a iphone 7 without computer
kondor19780726 [428]
You cant go to a specialist if you cannot figure it out or to someone who knows how to hack because the way iCloud is set up you wont be able to unless you can factory reset it by downloading jail break
4 0
2 years ago
Read 2 more answers
Which is a feature of audio editing software?
riadik2000 [5.3K]
D. It is used to add sound effects.
Hope this helps!
5 0
3 years ago
Read 2 more answers
Other questions:
  • Bluetooth is a common wireless protocol used to make pan connections. <br> a. True <br> b. False
    7·1 answer
  • An online company wants to conduct real-time sentiment analysis about its products from its social media channels using SQL.
    12·1 answer
  • This is question 2.5 Computer Science and I don't understand what is wrong<br><br>​
    15·1 answer
  • Write code that does the following: opens an output file with the filename number_list.txt, uses a loop to write the numbers 1 t
    8·1 answer
  • Does access provide email communication
    13·1 answer
  • In an information systems framework, ________ is the bridge between the computer side on the left and the human side on the righ
    14·1 answer
  • HELP PLEASE
    6·1 answer
  • How can learning opportunities for AI be extended to all
    6·1 answer
  • I need help!!!! 1.04
    9·1 answer
  • The name for the instructions you write to a computer in a program
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!