Answer to Question #260765 in C++ for binno

Question #260765

1.     Write a program that prompts the user to enter five test scores and then prints the average test score. (Assume that the test scores are decimal numbers.)


1
Expert's answer
2021-11-03T11:43:51-0400
#include <iostream>

int main()
{
    float s1, s2, s3, s4, s5;
    std::cout << "Enter five test scores: ";
    std::cin >> s1 >> s2 >> s3 >> s4 >> s5;

    if(!std::cin)
    {
        std::cout << "Error: invalid data\n";
        return 1;
    }

    std::cout << "Average test score is " << ((s1 + s2 + s3 + s4 + s5) / 5) << "\n";

    return 0;    
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS