Language C
Description It prompts the user to enter a subject name and three test scores. The application displays the average of the test scores.
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
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    float average, test_score_1, test_score_2, test_score_3;
    char subject_name[63];
    printf ("Enter the subject name: ");
    scanf ("%[^\r\n]", subject_name);
    (void) getchar ();
    printf ("Enter the value of test score 1: ");
    scanf ("%f", &test_score_1);
    (void) getchar ();
    printf ("Enter the value of test score 2: ");
    scanf ("%f", &test_score_2);
    (void) getchar ();
    printf ("Enter the value of test score 3: ");
    scanf ("%f", &test_score_3);
    (void) getchar ();
    average=(test_score_1+test_score_2+test_score_3)/3;
    printf ("Subject name: %s\n", subject_name);
    printf ("Value of average: %g\n", average);
    putchar ('\n');
    system ("pause");
    return EXIT_SUCCESS;
}