dimanche 23 janvier 2022

create a program wherein there is an initialized list of grades, and it will display the grades passed depending on the user input

This is the code I have made, however, what is being displayed is incorrect. Kindly teach me what do I need to fix.

#include <iostream>
#include <list>
using namespace std;

bool check(int passing){
    int g;
    if(g<=passing){
        return false;
    }else{
        return true;
    }
}

int main()
{
    int pg;

    cout<<"What is the passing grade?"<<endl;
    cin>>pg;

    list<int> grades = {100,90,93,95,92,98,97,99,96,94};
    grades.remove_if(check);
    for(int x : grades){
        cout<<x<<'\t';
    }
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire