Answer to Question #258313 in C++ for Alemnat

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. 


1
Expert's answer
2021-10-28T15:20:30-0400
#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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS