need help figuring out what to do with this assignment (guessing game using functions)

#include <iostream>
#include <string>
#include <ctime>
#include <iomanip>
using namespace std;


int levelSelect()
{
int level;

cout << "what difficulty would you like? 1(easiest) - 10 (hardest) : ";
cin >> level;
while ( ! (cin >> level)|| (level <1) || (level >10))
{
// Enter this loop if input fails because of invalid data.

cout << "Hey, please enter a valid number through 1-10 Try again: ";
cin.clear ();

cin.ignore (80, '\n'); //validates that correct data is entered
}

if (level >= 1|| level <=10) //sets level accoding to selection
{
cout << "level " << level << " has been selected, good luck" <<endl <<endl;
}



return level;
}

int main ()
{
int level, guess, number, guesscntr=0;
string name;
char playAgain;


cout << "good day, please enter your name: ";
cin >> name;
cout << "hello, " <<name << " lets test your psychic abilities!" <<endl <<endl;


level=levelSelect();
switch (level)//sets random number gen to level

{
case 1:
number=rand()%10+1;
cout <<"the number will be between 1 and 10" <<endl;
break;
case 2:
number=rand()%20+1;
cout <<"the number will be between 1 and 20" <<endl;
break;
case 3:
number=rand()%30+1;
cout << "the number will be between 1 and 30" <<endl;
break;
case 4:
number=rand()%40+1;
cout << "the number will be between 1 and 40" <<endl;
break;
case 5:
number= rand()%50+1;
cout << "the number will be between 1 and 50" <<endl;
break;
case 6:
number= rand()%60+1;
cout << "the number will be between 1 and 60" <<endl;
break;
case 7:
number= rand()%70+1;
cout << "the number will be between 1 and 70" <<endl;
break;
case 8:
number= rand()%80+1;
cout<< "the number will be between 1 and 80" <<endl;
break;
case 9:
number= rand()%90+1;
cout<< "the number will be between 1 and 90" <<endl;
break;
case 10:
number= rand()%100+1;
cout << "the number will be between 1 and 100" <<endl;
break;
}
cout << "please enter a guess :";
cin >> guess;
do
while (guesscntr <5)
{
if (guess > number)

{
cout << "too high, please enter another guess " ;
guesscntr++ ;
cin >> guess;
}
if (guess < number)
{
cout << " too low, please enter another guess ";
guesscntr++;
cin >> guess;
}
if (guess == number)
{
cout << "congratulations! you got it! :)" ;
break;
}
}




system ("pause");
}


above is my assignment so far, i am stuck i need to figure out how to fix the error i am getting ( system ("pause") is underlined and it is saying that it is expecting a "while"). i also need to figure out how to get input as to whether the user wants to play again, any tips and mistake corrections would be helpful :) thanks!
Please use code tags next time (the <> button to the right).

You have a stray "do" near the end. while loops don't need do in front of them.

http://www.cplusplus.com/doc/tutorial/control/
okay, thank you, now i do have another problem. each case picks different numbers, but it is always same every time its run (case 3 is always 12, case 2 is always 2) whats up with that ? :s
Oh thanks :D could never figure it out and it wasn't given in lectures
Topic archived. No new replies allowed.