Friday, March 27, 2009

Getting the Numbers of Failed Students


This is a code in a getting the number of the students who had made to passed and failed.

Code:

# include......
# include......

int main()
{
int passes = 0;
int failures = 0;
int student = 1;
int result;



while (student <= 10)
{
printf("Enter result (1=pass,2=Fail):");
scanf("%d", &result);
if (result == 1)
{
passes = passes + 1;
}
else
{
failures = failures + 1;
}
student = student + 1;
}
printf("Passed %d\n", passes );
printf("Failed %d\n", failures );
if ( passes > 8 )
{
printf("Raise Tuition\n");

}

getch();
}


Output:



2 comments:

Anonymous said...

john pa link q ha.......

Anonymous said...

john pa link q ha.......