Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // english
- //create a program to read the grades of a group of students and calculate the general average
- //also show the number of students that pass and fail the subject, grades are given 0 to 5
- //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
- //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
- #include <stdio.h>
- #include <conio.h>
- main()
- {
- float grade;
- float sum=0;
- float average=0;
- float i;
- int nstudents;
- int pass;
- int fail=0;
- printf("how many students are in your class: ");
- scanf("%d", &nstudents);
- for(i=1;i<=nstudents;i++)
- {
- printf("input the grade of each of your students: ");
- scanf("%f", &grade);
- sum=sum+grade;
- if(grade<3)
- {
- fail=fail+1;
- }
- else
- pass=pass+1 ;
- }
- printf("\n\nThe number of students that pass the subject is %d\n\n", pass);
- printf("the number of students that fails the subject is %d\n\n", fail);
- average=sum/nstudents;
- printf("the grade average of all students is : %.1f\n\n", average);
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement