Question:

Can someone help me write this program by C

by  |  earlier

0 LIKES UnLike

Can someone help me to write this program by C :

A computer science instructor need a program that averages the grades she receives on a quiz to her class. Each grade is an integer between 0 and 100. She does not know the number of grades at this time. Write a program that ask the user to enter quiz grades one at a time. After the user has completed entering grades, the program should display the number of grades entered and sum of the grades entered. The program should also display the average of the grades rounded to the nearest tenth.

 Tags:

   Report

2 ANSWERS


  1. You have to have code to accept user input. You then need to save that input to a temp spot in memory. You can right a array that accepts the imput data.  Then it is just simple sums and average equations. I hope that helps, but I won't do your homework for you.


  2. Since all you want is a summary instead of being able to echo back the individual scores at some point, you don't need to worry about dynamic arrays or anything like that. One solution's pseudocode:

    continuePrompt = 'Y'

    gradeCount = gradeSum = nextGrade = 0

    gradeAverage = 0.0

    while (continuePrompt == 'Y')

    display "Do you have another grade to enter?"

    receive continuePrompt and convert to uppercase

    case continuePrompt

    'N' : continue (and exit loop)

    'Y' : display "Enter next grade (0-100)"

    other: display "Please answer 'Y' or 'N'" and continue (branch to loop)

    end case

    receive nextGrade

    if (nextGrade < 0 || nextGrade > 100) display "Value between 0 and 100 only" and continue (branch to loop)

    gradeCount++

    gradeSum += nextGrade

    end while

    if (gradeCount==0) display "You didn't enter any grades"

    else

    gradeAverage = (gradeSum/gradeCount) * 1.0

    display "There were " gradeCount " grades with a cumulative score of " gradeSum " for an average score of " gradeAverage

    end if

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.