title: snake and ladder program
body: <pre><code>#include&lt;iostream&gt;
  #include&lt;string.h&gt;
  #include&lt;time.h&gt;
  #include &lt;cstdlib&gt;
  #define MAX_NUM 6
  using namespace std;
  int randomfunc(int &amp;score);
  int main()
  {
  int p1_score=0,p2_score=0;
  cout&lt;&lt;endl;
  cout&lt;&lt;endl;
  cout&lt;&lt;"========================================"&lt;&lt;endl;
  cout&lt;&lt;endl;
  cout&lt;&lt;"\t\t\t\t SNAKE AND LADDER GAME \t\t\t\t"&lt;&lt;endl;
  cout&lt;&lt;endl;
  cout&lt;&lt;"========================================"&lt;&lt;endl;
  cout&lt;&lt;endl;
  cout&lt;&lt;"\t\t\tdesigned by bennyyy\t\t\t"&lt;&lt;endl;
  cout&lt;&lt;"========================================"&lt;&lt;endl;
  int i;
  string player1,player2;
  
  srand(time(0));
  
  cout&lt;&lt;"enter the name of  player 1"&lt;&lt;endl;
  cin&gt;&gt;player1;
  cout&lt;&lt;"enter the name of the player 2 "&lt;&lt;endl;
  cin&gt;&gt;player2;
  cout&lt;&lt;"the position of player1 and player2 is 0 initially"&lt;&lt;endl;
  
  while(p1_score&lt;100 &amp;&amp; p2_score&lt;100)
  {
  
  cout&lt;&lt;player1&lt;&lt;" It is your turn press any key to play "&lt;&lt;endl;
  cin.get();
  randomfunc(p1_score);
  cout&lt;&lt;"your score is "&lt;&lt;p1_score&lt;&lt;endl;
  cout&lt;&lt;player2&lt;&lt;"it is your turn press any key to play"&lt;&lt;endl;
  cin.get();
  randomfunc(p2_score);
  cout&lt;&lt;"your score is "&lt;&lt;p2_score&lt;&lt;endl;
  
  }
  if(p1_score&gt;p2_score)
  {
  cout&lt;&lt;player1&lt;&lt;"is the winner"&lt;&lt;endl;
  }
  if(p2_score&gt;p1_score)
  {
  cout&lt;&lt;player2&lt;&lt;"is the winner"&lt;&lt;endl;
  }
  if(p1_score==p2_score)
  {
  cout&lt;&lt;"match is draw"&lt;&lt;endl;
  }
  }
  int randomfunc(int &amp;score)
  {
  int random;
  random=rand()%MAX_NUM;
  cout&lt;&lt;"your number is "&lt;&lt;random&lt;&lt;endl;
  score=random+score;
  switch(score)
  {
  case 98 :score=28;
       cout&lt;&lt;"you ran into a snake!"&lt;&lt;endl;
  
      break;
  case 95 :score=24;
  cout&lt;&lt;"you ran into a snake!"&lt;&lt;endl;
  
  break;
  case 92 :score=51;
  cout&lt;&lt;"you ran into a snake!"&lt;&lt;endl;
  
  break;
  case 83 :score=19;
  cout&lt;&lt;"you ran into a snake!"&lt;&lt;endl;
  
  break;
  case 73 :score=1;
  cout&lt;&lt;"you ran into a snake!"&lt;&lt;endl;
  
  break;
  case 69 :score=33;
  cout&lt;&lt;"you ran into a snake!"&lt;&lt;endl;
  
  break;
  case 64 :score=36;
  cout&lt;&lt;"you ran into a snake!"&lt;&lt;endl;
  
  break;
  case 59 :score=17;
  cout&lt;&lt;"you ran into a snake!"&lt;&lt;endl;
  
  break;
  case 55 :score=7;
  cout&lt;&lt;"you ran into a snake!"&lt;&lt;endl;
  
  break;
  case 52 :score=11;
  cout&lt;&lt;"you ran into a snake!"&lt;&lt;endl;
  
  break;
  case 48 :score=9;
  cout&lt;&lt;"you ran into a snake!"&lt;&lt;endl;
  
  break;
  case 46 :score=5;
  cout&lt;&lt;"you ran into a snake!"&lt;&lt;endl;
  
  break;
  case 44 :score=22;
  cout&lt;&lt;"you ran into a snake!"&lt;&lt;endl;
  
  break;
  case 8 :score=26;
  cout&lt;&lt;"luckyyy boy u got ladder"&lt;&lt;endl;
  
  break;
  case 21 :score=82;
  cout&lt;&lt;"luckyyy boy u got ladder"&lt;&lt;endl;
  
  break;
  case 43 :score=77;
   cout&lt;&lt;"luckyyy boy u got ladder"&lt;&lt;endl;
  
  break;
  case 50 :score=91;
  cout&lt;&lt;"luckyyy boy u got ladder"&lt;&lt;endl;
  
  break;
  case 54 :score=93;
  cout&lt;&lt;"luckyyy boy u got ladder"&lt;&lt;endl;
  
  break;
  case 62 :score=96;
  cout&lt;&lt;"luckyyy boy u got ladder"&lt;&lt;endl;
  
  break;
  case 66 :score=87;
  cout&lt;&lt;"luckyyy boy u got ladder"&lt;&lt;endl;
  
  break;
  case 80 :score=100;
  cout&lt;&lt;"luckyyy boy u got ladder"&lt;&lt;endl;
  
  }
  return score;
  }
  </code></pre>
  
  <p>since it is 2 players
  In output it is asking only player 2 to press key but for player 1 it is not asking. but shows the message and it performs next operations. for each player i gave cin.get() so that  it asks the user to press any key but this action is performed only at the player 2 . Can anyone tell me the mistake?</p>