Answers: Lesson 8

// Challenge 2

#include <iostream>

int main ()
{
 int marks[10];
 int total = 0, max = -1, min = 100;
 
 for (int i = 0; i < 10; i++) {
 std::cout << "Enter mark " ;
 std::cin >> marks[i];
 
 total += marks[i];
 if (max < marks[i]) {
 max = marks[i];
 }
 if (min > marks[i]) {
 min = marks[i];
 }
 }
 
 std::cout << "The maximum mark is " << max << std::endl;
 std::cout << "The minimum mark is " << min << std::endl;
 std::cout << "The average mark is " << total/10.0 << std::endl;
 
 return 0;
}
print