Complete the following function to return a value equal to 2
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

