#define _CRT_SECURE_NO_WARNINGS
#define NAME_LENGTH 10
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double myFunc(double x)
{
double y = (pow(x, 3)) - (3 * (pow(x,2))) + 2;
return y;
}
int main()
{
double y = 3;
myFunc(y);
printf("%d \n", y);
system("pause");
return 0;
}
To me this should be a very very simple formula. I'm not asking it to jump through many hoops, but it only outputs "0" no matter what value for "y" I give.
I am using Visual Studio 2013. I hovered my mouse over "y" and it said "y" equaled "2.0000" in the function, which is the correct output for this particular value of "y."
Assign the myFunc return value to y: y = MyFunc(y); And use the format %lf instead of %d.