Once again this is another one of Sams quizes, first here is the question: 10. Write a program that uses a function to find the average of five type float values entered by the user.
Now this is just a very simple example because last time it didn't work so this is like a "start simple and add on to it" kinda things.
Anyways this is my code:
Simple enough right nothing big, no errors, that isn't my question. My questions is why do you have to put spaces to enter your 5 values instead of enter a value hit enter and do that over and over again, I thought that would be wrong so I tried to spread out all of the scaf's into seperate ones but I still have to hit space instead of enter or else the whole thing dies, why is this and how can I change it?Code:#include <stdio.h> float a,b,c,d,e=0; double f=0; float average(float,float,float,float,float); int main(void) { printf("Please enter 5 values: "); scanf("%f",&a); scanf("%f",&b); scanf("%f",&c); scanf("%f",&d); scanf("%f",&e); f=float average(a,b,c,d,e); printf("Your values are: %f %f %f %f %f\n\n",a,b,c,d,e); return 0; }
I tried to continue on but this came up: (17) : error C2059: syntax error : 'type'
Now I just updated the code up above to fit my question now, how do I get rid of this type thing and for that matter what is it. My "index" describes it as a syntax error and that I may be missing a closing brace or that the error is in the line above but I simply cannot find it. I thought it would have been simple but I have now tried a few variations of the line that takes the variables(that is the error line)but I just can't get it...any help?