The output format:
According to the following format:
Business=average score
Count=pass number
Input the sample:
5
77, 54, 92, 73 60
My code:
# include
Int main ()
{
Int the count, I, n.
Double grade, total business;
The scanf (" % d ", & amp; N);
Total=0;
count=0;
for (i=1; i<=n; I++)
{
Lf the scanf (" % ", & amp; Grade).
Total=total + grade;
If (grade & gt;=60)
{
count++;
Business=total/n.
}
Else if (0 & lt; Grade & amp; & Grade<60)
{
count=0;
Business=total/n.
}
The else
{
Business=0;
count=0;
}
}
Printf (" business=% 1 f \ n ", business);
Printf (" count=% d \ n ", count);
return 0;
}
Why when the input sample count=3? Should not for 4?
CodePudding user response:
# include & lt; Stdio. H>
#include
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# pragma argsused
Int main (int arg c, char * argv [])
{
Int the count, I, n.
Double grade, total business;
Total=0;
count=0;
Printf (" please enter the number of students: ");
The scanf (" % d ", & amp; N);
Printf (" please enter the % d student performance: ", n);
for (i=1; i<=n; I++)
{
Lf the scanf (" % ", & amp; Grade).
Total=total + grade;
If (grade & gt;=60)
{
count++;
}
}
Business=total/n.
Printf (" average score=% 1 f \ n ", business);
Printf (" pass number=% d \ n ", count);
return 0;
}
CodePudding user response:
What is this you writeCodePudding user response:
Why do you count of s? Less than 60?CodePudding user response:
The