Advertisement
alvasalrey

student grades . c

Aug 15th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. // english
  2. //create a program to read the grades of a group of students and calculate the general average
  3. //also show the number of students that pass and fail the subject, grades are given 0 to 5
  4. //the student will pass the subject with a 3 as minimum, the program must ask for the number of students and then let the teacher
  5. //input the final grade number for each, at the end the program must show the general average of the class , and how many pass or fail the class
  6.  
  7.  
  8.  
  9.  
  10. #include <stdio.h>
  11. #include <conio.h>
  12.  
  13. main()
  14. {
  15. float grade;
  16. float sum=0;
  17. float average=0;
  18. float i;
  19. int nstudents;
  20. int pass;
  21. int fail=0;
  22.  
  23. printf("how many students are in your class: ");
  24. scanf("%d", &nstudents);
  25.  
  26. for(i=1;i<=nstudents;i++)
  27. {
  28. printf("input the grade of each of your students: ");
  29. scanf("%f", &grade);
  30. sum=sum+grade;
  31. if(grade<3)
  32. {
  33. fail=fail+1;
  34. }
  35. else
  36. pass=pass+1 ;
  37. }
  38.  
  39. printf("\n\nThe number of students that pass the subject is %d\n\n", pass);
  40. printf("the number of students that fails the subject is %d\n\n", fail);
  41. average=sum/nstudents;
  42. printf("the grade average of all students is : %.1f\n\n", average);
  43.  
  44.  
  45.  
  46. getch();
  47.  
  48.  
  49.  
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement