How do i get the loop to go back and prompt using for a valid number?


using namespace std;

int main ()
    string firstName;
    string lastName; 
    int score1, score2, score3, score4, score5;
    float totalpoints;


    cout<<"Please enter the student first and last name: ";
    cout<< endl; 

cout<<"Please enter the student's FIVE program scores"<<endl;
    cout<<"Each score must be an integer between 0 & 100:"<<endl;

    cout<<"Please enter the first program score: ";

    if (score1>100) 
       cout<<"Invalid Number";
    else if (score1<0)
         cout<<"Invalid Number";
    cout<<endl<<"Press any key to continue."<<endl;

 return 0;   

Well, for starters, you need to actually create a loop. You don't have any loop structure in this code. Just remember, everything that you want to execute multiple times needs to be within the statement block controlled by the loop.

void someFunction() {

  //any code here will only run once

  while (someCondition == true) {
    //any code here will repeat as long as someCondition == true
  }                                           //end while

  //any code here will only run once

}                                             //end main()

NOTE: There are also do-while and for loops. This example only shows the standard while loop.

More information.

you can do

while(score1>100 || score1<0) // will loop until proper number entered
cout<<"invalid number,enter again\n";
commented: Don't just give away code. :( -1