I have the following code, and the only thing I can physically see it evaluating is line 18 which is the call to printf(). It doesn’t go any further.
#include <stdio.h>
#include <stdlib.h>
int main (void) {
int cylNum;
double disp, pi, stroke, radius;
pi = 3.14159;
printf("Welcome to the Engine Displacement Calculator!\n");
cylNum = scanf("Enter number of cylinders (then press enter): \n");
stroke = scanf("Enter stroke: \n");
radius = scanf("Enter radius: \n");
disp = radius * radius * pi * stroke * cylNum;
printf("Displacement is: %f", disp);
getchar();
printf("Press any key to exit!");
return 0;
}
the variables you’re trying to read should be parameters to “scanf()”, not the result of scanf():