fork download
  1. #include <stdio.h>
  2. // Given a class of 10 students, calculate the numbers of student who pass an exam. In order to pass, students need to scrore the grade of A, B or C
  3.  
  4. int main(void) {
  5. int grade, count, sum;
  6. count = 0;
  7. sum = 0;
  8.  
  9. while (count < 10) {
  10. printf (" Enter the grade \n");
  11. scanf ("%d", &grade);
  12. if (grade >= 68) {
  13. printf ("Pass \n");
  14. count = count + 1; }
  15. else {
  16. printf ("False \n");
  17. }
  18. }
  19. sum = count;
  20. printf ("Total of students who pass: %d \n",sum);
  21.  
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 10320KB
stdin
50
100
80
7593
60
0
85
95
45
100
stdout
 Enter the grade 
False 
 Enter the grade 
Pass 
 Enter the grade 
Pass 
 Enter the grade 
Pass 
 Enter the grade 
False 
 Enter the grade 
False 
 Enter the grade 
Pass 
 Enter the grade 
Pass 
 Enter the grade 
False 
 Enter the grade 
Pass 
 Enter the grade 
Pass 
 Enter the grade 
Pass 
 Enter the grade 
Pass 
 Enter the grade 
Pass 
Total of students who pass: 10