How to Capture Command Line Information

1

How can I do that, when typing a character, I can read the next one without the loop continuing until the iteration count is finished? Follow the code below.

#include <iostream>
using namespace std;

int main(){

    int aluno;
    float a,b,c,d,p;

for(int n=1; n<=5000; n++){

    cout<<"Digite o nome do aluno"<<endl;
    cin>>aluno;
    cout<<"Digite a nota do primeiro bimestre"<<endl;
    cin>>a;
    cout<<"Digite a nota do segundo bimestre"<<endl;
    cin>>b;
    cout<<"Digite a nota do terceiro bimestre"<<endl;
    cin>>c;
    cout<<"Digite a nota do quarto bimestre"<<endl;
    cin>>d;

    p=(a+b+c+d)/3;

    if(p>=6){
        cout<<"O aluno "<<aluno<<" foi aprovado, a media dele corresponde a  "<<p<<endl;
    }

    else{
        cout<<"O aluno "<<aluno<<" foi reprovado, a media dele corresponde a "<<p<<endl;
    }

    cout<<"..........................................................."<<endl;
}

    return 0;
}
    
asked by anonymous 21.09.2017 / 21:06

1 answer

4

Two things:

  • % with% will be repeated 5000 times. I think it's a lot of repetition to get data on the keyboard until it's done
  • You declared the student as an integer ( for(int n=1; n<=5000; n++) ). The correct would be to declare it as a string, that is, change the declaration to int aluno;
21.09.2017 / 21:19