#include <iostream>
#include <math.h>
using namespace std;
int x; // degree of the polynomial
int value; // f(x)
int pow(int x, int a)
{
int i;
int z=a;
if(x==1)return a;
else
{
for(i=2;i<=x;i++)
z*=a;
}
return z;
}
int main()
{
cout << "Enter the value of x that you
would like to evaluate the equation for: " << endl;
cin >> x;
if(x==0)
{
value=7;
}
else
{
value = pow(x,2)+pow(x,5);
}
cout<<"f(x) = "<<value<<" for
x = " <<x<< endl;
}
Wite a ctt pkoqam computhing the following function pxototype pxogecm computi g tho following Int Pow...
In SML programming write a function pow of type real * int -> real that raises a real number to an integer power. Your function need not behave well if the integer power is negative.
program. 13. What's the output of the following program? #include< iostream> #include&math> using namespace std; int p 7; void main) extern double var int p abs(-90); system( "pause"); double var = 55; 14. How many times does "#" print? forlint i 0;j< 10; +ti) if(i-2141 6) continue; cout<< "#"; 15. Write the function declaration/prototype for a, pow function b floor function 16. State True or False a. b. c. d. e. isupper function returns a double value for loop is...
Write a program that contains a main function, a “double custom_operator_function(int op_type, double x, double y)”, a “double min(double,double)”, a double max(double x,double y), and a double pow(double x, int y). The main function is used to call the custom operator function. Next, the custom operator function calls the min/max/pow functions based on the op_type. From the main, call the custom operator function with the three inputs 1/-3/5, 2/4/5, and 3/4/5. Print the result of each input to screen. i)...
Examine the function below and answer the following questions. int gLobal = 25; // declared outside function int func( int X, char *Y, BYTE Z ) { int a; char b[] = “The lazy dog ate the red fox before jumping over it.” char *c; c = (char *) malloc(512K); a = b[0]; return a; } -- b. How many bytes used on the stack for ‘Z’. c. How many 4K pages of physical memory are needed for the above...
(a) Consider the following C++ function: 1 int g(int n) { 2 if (n == 0) return 0; 3 return (n-1 + g(n-1)); 4} (b) Consider the following C++ function: 1 bool Function (const vector <int >& a) { 2 for (int i = 0; i < a. size ()-1; i ++) { 3 for (int j = i +1; j < a. size (); j ++) { 4 if (a[i] == a[j]) return false; 5 6 } 7 return...
C language
Write a function to compute the power a^m, where n greaterthanorequalto 0. It should have the following prototype:/* Sets *p to the n' th power of a and returns 0, except * when n < 0 or p is NULL, in which case it returns -1. */int power(int a, int n, int * p); Write a unit test in a main function to test various values. The following code sequence illustrates how to use printf to provide informative...
Complete the definition of the following function void find_two_largest (int 3[), int n, int *largest, int * second_largest); When passed an array a of length n, the function will search a for its largest element and second largest element, storing them in the two variables pointed to by largest and second_largest, respectively. Test your function in the main function.
What is the selection that best describes the following statement: int function( int, double [ ] ); A) function prototype B) function call C) function definition D) none of the above
Assume the following type definition … typedef int (*Pf) (int) ; Write a C function apply such that … the two inputs to function apply are … pf, which is a pointer to a function and is of type Pf an int value N function apply returns the result of applying to N the function pointed to by pf
Given the following recursive function: unsigned int mymod( unsigned int a, unsigned int b ) { if( a < b ) return a; return mymod( b - a, b ); } the function call mymod(5, 2) will Select one: a. execute infinitely and terminates with an error. b. execute until some if-condition matches. c. not compile, it will generate a compilation error. d. return the value: 1