Complete the following function to return a value equal to 2

Complete the following function to return a value equal to 2 - x^3 - x^2 + x: int myFunc(int x) { } Insert a code segment to call the previous function in compute and display 2 - 6^3 - 6^2 + 6 like this 2 - 6 cubed - 6 squared + 6 is -244 Feel free to declare any local variables that you think you may need:

Solution

3) find the function which can return 2 - x^3 - x^2 + x as below:

int myFunc(int x)

{

int c;

c = 2 - pow(x,3) - pow(x,2) + x;

return c;

}

i am using pow(); function which is inbuilt function in c

also you need to use

#include<stdio.h>

#include<math.h> to use this function.

so it wiil return value of c = 2 - x^3- x^2 + x

find the c code which call the function myFunc as below:

#include <stdio.h>
#include <math.h>

int myFunc(int);

void main(){
int y;
int x;
y = myFunc(6);
printf(\"%d\",y);
  
}

int myFunc(int x) {
int c;
   c = 2 - pow(x,3) - pow(x,2) + x;
   return c;
}

so inside void main we have,

y = myFunc(6);

it will call myFunc with value 6 that is x = 6

and inside myFunct we have,

c = 2 - x^3 - x^2 + x

x = 6 so we get c = -244

so value of c is assigned to y

and it will print -244 also

 Complete the following function to return a value equal to 2 - x^3 - x^2 + x: int myFunc(int x) { } Insert a code segment to call the previous function in comp
 Complete the following function to return a value equal to 2 - x^3 - x^2 + x: int myFunc(int x) { } Insert a code segment to call the previous function in comp

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site