• Language

    C

  • Description

    A program to assess students in high school who offer three subjects: chemistry, physics, and mathematics in their exams. The program should for every student calculate the average and award a pass remark if the average is greater than or equal to %50, and mark of fail if below %50.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

int main (void)
{
    float average, score_of_chemistry, score_of_mathematics, score_of_physics;
    char key_repeat;
    do {
        system ("cls");
        printf ("Enter the value of score of chemistry: ");
        scanf ("%f", &score_of_chemistry);
        (void) getchar ();
        printf ("Enter the value of score of mathematics: ");
        scanf ("%f", &score_of_mathematics);
        (void) getchar ();
        printf ("Enter the value of score of physics: ");
        scanf ("%f", &score_of_physics);
        (void) getchar ();
        average=(score_of_chemistry+score_of_physics+score_of_mathematics)/3;
        if(average>0.5)
            printf ("The student passed.\n");
        else
            printf ("The student failed.\n");
        printf ("Value of average: %g\n", average);
        putchar ('\n');
        printf ("Do you wish to repeat the process? (Y/N): ");
        do {
            key_repeat = (char) getch();
        } while (key_repeat!='y' && key_repeat!='n' && key_repeat!='Y' && key_repeat!='N');
        putchar ('\n');
    } while (key_repeat=='y' || key_repeat=='Y');
    return EXIT_SUCCESS;
}