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]
4 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]4 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
You have created a new storage space using a single 500 GB external USB 3.0 drive. The drive is becoming full, so you add anothe
Dimas [21]

Answer:

In the clarification section following, the definition including its query is mentioned.

Explanation:

  • I believe we possess 2 other discs except for the major memory card-a USB 500 GB USB 3.0 drive, just one TB USB 2.0 drive. So we're making a two-array mirrored storage space resilience kit. We get a warning when we duplicate files from either the C: drive towards this second adaptation that you should be running out of places.
  • That was because these need to have a backup process around each other discs throughout the situation of a two-way mirror.
  • This serves to protect the organization from disc failure and enhances the overall efficiency of the device. Thus, even when copying, even though only several 100 MB has also been cut and pasted to something like the disc, the disc intercepts that the information collected from either the 500 GB drive as well as the major disc must be stored there. And that is how the alert arrives that throughout the new trip, we're running out of space. So this is how they so easily get the alarm.

3 0
3 years ago
Select all statements below that are TRUE for For...Next loops. A. It is used for a fixed number of iterations. B. It is used fo
sasho [114]

Answer:

A and C

Explanation:

The for next loop is used for a fixed number of iterations which is usually indicated in the syntax. It uses a counter that increments on each iteration. The loop terminates when the counter reaches the number of initially specified iterations. It is different from a while loop which depends on a specified condition evaluating to the Boolean 'true'.

7 0
3 years ago
Design and implement a program (name it GradeReport) that uses a switch statement to print out a message that reflect the studen
Korolek [52]

Answer:

#include <iostream>

using namespace std;

int main()

{

   int grade;

   

   cout << "Enter student's grade: ";

   cin >> grade;

   

   switch (grade)  

       {

       case 100 ... 1000:

           cout << "That grade is a perfect score. Well done.";

           break;

       case 90 ... 99:

           cout << "That grade is well above average. Excellent work.";  

           break;

       case 80 ... 89:

           cout << "That grade is above average. Nice job.";  

           break;

       case 70 ... 79:

           cout << "That grade is average work.";  

           break;

       case 60 ... 69:

           cout << "That grade is not good, you should seek help!";  

           break;

       default:

           cout << "That grade is not passing.";

           break;

       }

   return 0;

}

Explanation:

*The code is in C++

First, ask the user to enter a grade

Then, check the grade to print the correct message. Since you need to check the ranges using switch statement, you need to write the minimum value, maximum value and three dots between them. For example, 70 ... 79 corresponds the range between 70 and 79 both inclusive.

Finally, print the appropriate message for each range.

Note: I assumed the maximum grade is 1000, which should more than enough for a maximum grade value, for the first case.

6 0
3 years ago
3.This exercise considers the implementation of search algorithms in Prolog. Suppose that successor(X,Y) is true when state Y is
zloy xaker [14]

Answer:

c

Explanation:

3 0
3 years ago
In a traditional systems development environment, security issues usually are less complex than with web-based systems, because
NikAS [45]

Answer:

The answer is "True".

Explanation:

Traditional techniques of application development were focused on pre-development stages. These control system flows through claims to design and upgrades and will then tests and repair are directional there.

  • It enables the user to create and run a machine-based data system.  
  • It uses program and device, that specifically the solutions, that enable manual information to be processed.
6 0
4 years ago
Other questions:
  • By what date must federal taxes typically be filed and sent to the IRS?
    7·1 answer
  • What does a closed-envelope icon next to an e-mail message header indicate?\?
    8·1 answer
  • Respuestas de un examen parcial en introducción to computer
    12·1 answer
  • Fair use laws allow you to use other people’s copyrighted information in which of the following purposes? A: For profit Purposes
    6·2 answers
  • Change the screen resolution so you can view more information on your screen. Use the resolution that enables you to fit the mos
    7·1 answer
  • The LPN/LVN cares for an older client admitted to the hospital for treatment of a fractured femur. The LPN/LVN notes the client
    10·2 answers
  • By default, headers and footers apply to
    9·1 answer
  • How can your microsoft word processing skills affect overall writing skills on the job?<br><br>​
    7·1 answer
  • In which area is composing for games different from composing for movies?
    12·1 answer
  • Plz help code practice for python
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!