Home > Back-end >  For a class and grade point average
For a class and grade point average

Time:06-04

'for a class of grade point average'

Why I don't have the result by return later???????

Thank you brother!

# include "stdio.h"
Float the main ()
{
Float y=0, score, sum=0, I=1;
The scanf (" % f ", & amp; Score);
While (score! )
='\ n'{
Sum=sum + score;
i=i+1;
Y=sum/I;
The scanf (" % f ", & amp; Score);
}
Printf (" the average grades of this class is: % f ", y);
}

CodePudding user response:

Score is a floating point number, how can do comparison and '\ n' characters?

With each other as exit, not a good design method, passing in a lot of input function is used to determine the input

You can use 0==the scanf (" % f ", & amp; Score), when you enter is not a floating point number, the scanf returns 0, to quit

CodePudding user response:

Fun
reference 1 floor response:
score is a floating point number, how can do comparison and '\ n' characters?

With each other as exit, not a good design method, passing in a lot of input function is used to determine the input

You can use 0==the scanf (" % f ", & amp; Score), when you enter is not a floating point number, the scanf returns 0, to exit the

Thank you , I know,

CodePudding user response:

I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related