/* will need to be linked with -lm for powf */#include <stdio.h>#include <math.h>#define BUFSIZE 16int main(int argc, char **argv) { float result, x; char buf[BUFSIZE]; printf("3X^3 -5x^2 + 6\n"); for( ;; ) { x = 0.f; printf("What is X?\n"); /* read at most BUFSIZE bytes from stdin into buf */ fgets(buf, BUFSIZE, stdin); /* now parse buf with sscanf since sscanf returns the number of matches made, we know that returning 1 means the user entered a float */ if( sscanf(buf, "%f", &x) == 1 ) break; } result = (3 * powf(x, 3)) - (5 * powf(x, 2)) + 6; printf("the result is: %f\n", result); return 0;}