Please help me code using C Write a function that receives a

Please help me code using C++

Write a function that receives a parameter “x” of the type double then computes and returns the value of the following expression: (3x squared) square roof of x / x-sin(x).

Solution

//Header file required to compute the expression
#include <iostream>           // input output header

#include<math.h>           //math function header
double expression(double x);       //function declaration to compute expression
using namespace std;              
int main()                        //main function begins
{
double num,ans;                //varible declarations

cout<<\"Enter any double type x value: \";        //prompt for x value
cin>>num;                                        //read x value
ans=expression(num);                           //calling function with double type argument
cout<<\"\ Value of Expression is : \"<<ans;            //display output
return 0;
}
double expression(double x)               //function defination
{
   double temp=(x/(x-sin(x)));               //calculation part
   return 3*pow(x,2)*pow(temp,0.5);           //return final expression value
  
}


Output :

Enter any double type x value: 30

Value of Expression is : 2656.61

Please help me code using C++ Write a function that receives a parameter “x” of the type double then computes and returns the value of the following expression:

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site