1. I need to write a program in c that prompts the user to enter the scores for four quizzes each worth a maximum of 100 points. Your program should compute the average score and display this average together with a letter grade based on the following scale:

90 - 100 A
80 - 89 B
70 - 79 C
60 - 69 D
0 - 59 F
Your program must also check for valid input i.e. the score can not be less than zero or greater than 100.

I have throughly read the chapter and completed the hands-on but I am lost

#include <stdio.h>
int main(int argc, char **argv) {
    int i,v;
    float a;
    char s[2];
    i=v=0;
    for(;i<4;i++) 
        v+=atoi(gets(s));
    if(90<(a=(float)v/4.0))
    (void)printf("avg == %2.2f\tA\n", a);
    else if(80<(a=(float)v/4.0))
    (void)printf("avg == %2.2f\tB\n", a);
    else if(70<(a=(float)v/4.0))
    (void)printf("avg == %2.2f\tC\n", a);
    else if(60<(a=(float)v/4.0))
    (void)printf("avg == %2.2f\tD\n", a);
    else (void)printf("avg == %2.2f\tF\n", (float)v/4.0);
}

I wrote this program (a little different) 5 grades but it doesn't print the letter grade although it would be simple. If you wan't you can use it as a reference, however it is written in C++ so you will have to change a bunch. The snippet name is Average Calculator

This article has been dead for over six months. Start a new discussion instead.