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
BADM-Provide a reflection of at least 500 words (or 2 pages double spaced) of how the knowledge, skills, or theories of this cou
barxatty [35]

Answer:

WooW We Have To All This Which Class can you Please tell

5 0
2 years ago
How do you fix peer answer bad gateway 502. Please help
kondaur [170]

Answer:

Reload the page.

Look for server connectivity issues.

Check for any DNS changes.

Sift through your logs.

Fix faulty firewall configurations.

Comb through your website's code to find bugs.

Contact your host.

Explanation:

7 0
3 years ago
A prime number is a number that is only evenly divisible by itself and 1. For example, the number 5 is prime because it can only
Advocard [28]

Answer:

I need some time i answering your question please follow me and thank(sanybody have any friends cute girl or cute sardarni he is my classmate His name Was Kushi ask to Please follow me)

4 0
2 years ago
How many bits would be needed if there is 15 students in the class
Anni [7]

Answer:

Bits??

Explanation:

8 0
2 years ago
To test dns configuration by resolving a host name to ip address, which command or commands can you use
Helga [31]

ping, tracert or nslookup can all be used.

4 0
3 years ago
Other questions:
  • Who is the last person appointed to the u.s supreme court
    11·1 answer
  • If Denise specifies Jan? as a search criterion, Excel will locate all of the following records EXCEPT ____.
    9·1 answer
  • Write an application named [LastName]_MultiplicationTable and create a method that prompts the user for an integer value, for ex
    11·1 answer
  • What is the maximum input current fr transformer T10266
    10·1 answer
  • C++
    11·2 answers
  • What are tributaries
    15·2 answers
  • Is it good to work out at the gym one day with hands then the next with feet, then a pattern?
    11·2 answers
  • Write a program that produces an expense report for a trip to Lagos, Nigeria. Use the Internet to research the cost to travel to
    13·1 answer
  • One benefit proprietary licensed software is that it
    9·1 answer
  • Who is the best valorant character
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!