Question #258313

1.     Write a function accepts list of marks of students and counts the number of students who have scored marks greater than 20 in an exam out of 30. The total number of students who took the test is to be entered from the keyboard. 


Expert's answer

#include <iostream>

void Write(int n) 
{
    int counts{ 0 };
    int mark{ 0 };
    for (int i = 1; i <= n; i++) 
    {
        std::cout << "Enter the mark of " << i << " student: ";
        std::cin >> mark;
        if (mark > 20 && mark <= 30)
            counts++;
    }
    std::cout << "The number of students who have scored marks greater than 20 in an exam out of 30: ";
    std::cout << counts;
}


int main()
{
    int n;
    std::cout <<"Enter the number of students: ";
    std::cin >> n;
     Write(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!

LATEST TUTORIALS
APPROVED BY CLIENTS