Ask Question
19 October, 12:40

Write a program that will ask the user to input 5 test grades. Store the test grades in an array. Last output the tests from the array onto the display screen.

Sample Run: Your program must run exactly like the example below.

Enter grade 1: 100

Enter grade 2: 90

Enter grade 3: 89

Enter grade 4: 77

Enter grade 5: 100

Grade #1: 100

Grade #2: 90

Grade #3: 89

Grade #4: 77

Grade #5: 100

Press any key to continue

+3
Answers (1)
  1. 19 October, 15:15
    0
    Following are the program of C++

    #include / / header file

    #include / / header file

    using namespace std; / / namespace

    int main () / / main function

    {

    int grade[5], k; / / declaration of array and variable

    for (int i = 0; i< 5; i++) / / iterating over the loop

    {

    cout << "Enter grade ";

    cin >> grade[i]; / / read the grade by the user

    }

    k=0;

    while (k<5) / / iterating over the loop

    {

    cout << "Grade #" << k + 1 << ": ";

    cout << grade[k] << endl; / / display the grade

    k++; / / increment of i

    }

    }

    Output:

    Enter grade 45

    Enter grade 5

    Enter grade 8

    Enter grade 6

    Enter grade 7

    Grade #1: 45

    Grade #2: 5

    Grade #3: 8

    Grade #4: 6

    Grade #5: 7

    Explanation:

    The description of the program is given below.

    Declared an array "grade" of int type Read the grade elements by the user using the for loop finally, display the grade in the given format which is mention in the question.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a program that will ask the user to input 5 test grades. Store the test grades in an array. Last output the tests from the array onto ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers