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
Consider a physical transmission medium of capacity C bits/sec between two stations that have I bits of information sent/receive
levacccp [35]

Answer:

Check the explanation

Explanation:

when calculating the total time to send the I bits of information or The packet delivery time or latency which can be said to be the amount of time from when the first bit leaves the point of transmission until the last is received. When it comes to a physical link, it can be computed or determined as: Packet delivery time = Transmission time + Propagation delay.

Kindly check the attached image below to get the step by step explanation to the above question.

5 0
3 years ago
An array is sorted (in ascending order) if each element of the array is less than or equal to the next element .
Aleks04 [339]

Answer:

// The program below checks if an array is sorted or not

// Program is written in C++ Programming Language.

// Comments are used for explanatory purpose

//Program Starts here

#include<iostream>

using namespace std;

//Function to check if the array is sorted starts here

int isSorted(int arr[], int count)

{

// Check if arrays has one or no elements

if (count == 1 || count == 0) {

return 1;

}

else

{

// Check first two elements

if(arr[0] >= arr[1])

{

return 0; // Not sorted

}

else

{ // Check other elements

int check = 0;

for(int I = 1; I<count; I++){

if (arr[I-1] > arr[I]) { // Equal number are allowed

check++; // Not sorted

}

}

}

if(check==0)

return isSorted(arr, count - 1); //Sorted

else

return 0; // Not sorted

}

// Main Method starts here

int main()

{

int count;

cin<<count;

int arr[count];

for(int I = 1; I<=count; I++)

{

cin>>arr[I-1];

}

int n = sizeof(arr) / sizeof(arr[0]);

if (isSorted(arr, n))

cout << "Array is sorted";

else

cout << "Array is not sorted";

}

8 0
3 years ago
¿Cuáles son las dos ideas que confrontan en la "Revolución Tecnológica", cuando se refieren a la producción?
jeyben [28]

Answer:

._.  dont know spanish

Explanation:

6 0
2 years ago
If a while loop iterates forever,what is the most likely cause?
miv72 [106K]

Answer:

Runtime error probably. The program won't make it past the while loop in the code.

5 0
1 year ago
Collaborative filtering is
vazorg [7]

Answer:

A: used by ISP's to filter out email SPAM

C: a way to help an individual focus on best choices when deciding what to watch or buy.

Explanation:

Collaborative filtering uses a community-based approach to filter spam. It works by collecting numerous email users from around the world. By doing this, it becomes possible for users to flag emails that are spam and those that are legitimate.

Also Collaborative Filtering is one of the most efficient techniques for building a system that can help a user when it comes to recommending best choices based on information from a large number of users.

4 0
3 years ago
Other questions:
  • Consider the following general code for allowing access to a resource:
    13·1 answer
  • Numeric data is stored in ___________ for direct processing.
    10·2 answers
  • A web browser allows you to manage computer files and programs true false
    15·1 answer
  • When might be the best time to start saving for retirement?
    11·2 answers
  • Which nmap switch is used to detect target OS and services?<br> a -S<br> b -p<br> c -F<br> d -A
    8·1 answer
  • If the supply of computer engineers increases at the same time that the demand for these workers decreases, what would be the MO
    7·1 answer
  • While the Internet is used to share many useful services and information, there are growing concerns about the way that the Inte
    8·1 answer
  • What is a feature of readable code?
    12·2 answers
  • WHICH PROGRAMMING LANGUAGES ARE THE BEST AND COMPATIBLE FOR 3D PRINTERS?
    12·1 answer
  • How media platform drives globalization.<br> Advantages and disadvantages of using media platforms?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!