I am currently a student in C, and I'm trying to learn functions. However, the very first demo code the book gave just does not work (I keep getting undefined results). I've triple checked and I have code down exactly, so I'm wondering if they forgot to include a header or if I'm missing something.
This keeps outputting
double average (double a, double b)
return (a + b) / 2;
double x, y, z;
printf("Enter three numbers:");
scanf("%1g%1g%1g", &x, &y, &z);
printf("Average of %g and %g: %g\n", x, y, average(x, y));
printf("Average of %g and %g: %g\n", y, z, average(y, z));
printf("Average of %g and %g: %g\n", x, z, average(x, z));
Enter three numbers:234
Average of 1.8e-307 and 1.8e-307: 1.8e-307
Average of 1.79046e-307 and 7.96789e+268: 3.98394e+268
Average of 1.79064e-307 and 7.96789e+268: 3.98394e+268
Process returned 0 (0x0) execution time : 1.391 s
Press any key to continue.