I simple program that I wrote two years ago that will ask the user to give a series of grades pass and failing grades and then our program will counter how many grades given by the user is failed and passed. The code also teaches how to write and use one dimensional array in C language.
If you have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Program Listing
#include <stdio.h>
#include <stdlib.h>
main() {
int list=0,pass=0,fail=0, grades[5];
printf("\n\t\tPASS AND FAIL LISTER 1.0");
printf("\n\n");
for (list=0; list < 5; list++) {
printf( "Enter Grade No %d :", list+1 );
scanf("%d",&list[grades]);
}
for (list=0; list < 5; list++) {
if (list[grades] >= 75) {
pass++;
}
else {
fail++;
}
}
// display pass grades and failed grades
printf("\n");
printf("\n==============================");
printf("\n====== Generated Report ======");
printf("\n==============================");
printf("\n\n");
printf( "Passed Grades => ");
for (list=0; list < 5; list++)
{
if (list[grades] >= 75) {
printf(" %4d ",list[grades] );
}
}
printf("\n");
printf("Failed Grades => ");
for (list=0; list < 5; list++)
{
if (list[grades] < 75) {
printf(" %4d ",list[grades] );
}
}
printf("\n");
printf("\nNumber of Passed Grades => %d. ",pass);
printf("\nNumber of Failed Grades => %d. " ,fail);
printf("\n\n");
system("PAUSE");
}
// End of Code