Ask Question
10 January, 22:55

Given an array of primitive integers named grades, fill in the blank to complete the following code that calculates the average of all the grades: double average = 0; average + grades[ average ( = grades. length; Use proper spacing per the course style guide. Do not include additional spaces at the beginning or end.

+4
Answers (1)
  1. 10 January, 23:21
    0
    C+ + snippet is given below with appropriate comments and explanation

    Explanation:

    Code snippet:

    double average=0; //declaring variable

    //using for loop

    for (int i=0; i
    {

    average+=grades[i]; //add each grade to average

    }

    average/=grades. length; //find average

    Explanation:

    Above code snippet need a for loop to add each grade from the array to the variable average,

    average/=grades. length; this will compute average.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Given an array of primitive integers named grades, fill in the blank to complete the following code that calculates the average of all the ...” in 📘 Engineering 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