Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

can anyone please help and tell me why this program doesnt run????

+11 votes
asked Apr 24, 2023 by WHITELIGHT UNSEEN (370 points)
#include <iostream>
#include <string>

using namespace std;

int main(){
    string asker;
    string asked;
    string temp;
    string asker_two;
    string asked_two;
   string asker_three;
   string asked_three;
    string asker_four;
    string asked_four;

    srand((unsigned) time(NULL));

    int numOfPlayers;
    
    cout<<"Please Enter numbers of players"<<endl;
    cin >> numOfPlayers;
    
    string players[numOfPlayers];
    
    for(int x=0;x<numOfPlayers;x++){
        
        cout <<"Please enter player "<<x<<" name: ";
        cin >> players[x];
        cout <<endl;
    }
    
    cout <<" All players are successfully stored"<<endl;
    
    
    

 int random = rand() % (numOfPlayers-1);
 //cout <<"Random number is "<<random<<endl;
 
 cout <<"Now we are going select who is out of the category"<<endl;
 cout <<"Press Enter to begin"<<endl;
 
    temp = cin.get();
    temp = cin.get();
 
 for (int x=0;x <numOfPlayers;x++){
    
     cout <<"\n\n\n\n\n\n\n\n\nhand the device to " << players[x]<< " and click enter";
     temp = cin.get();

     if (random == x){
        
        

      
        
         cout <<"\n\n\n\n\n\nPlayer: "<<players[x]<<"\n\n\n\nshhh! you are out of the category pretend to be knowing the salfah guess the category by other's questions"<<endl;
        temp = cin.get();
      }else{
         cout <<"\n\n\n\n\n\nPlayer: "<<players[x]<<" is in the category,try to ask other's questions till we find who is out of the category "<<endl;
        temp = cin.get();
  
                 cout <<"\n\n\n\n\n\n\n\n\n\n\n\n\n\nquestion time everyone must ask others till we can get who is out of the category who wants to ask asker name and asked name please asker first"<<endl;
 cin >> asker;
 cin >> asked;
 cout <<"ok "<<asker<<" ask  "<<asked<<" a question about the category that appeared just now and click enter when done";
 temp = cin.get();
 cout <<"ok now 2 need to ask again please choose a asker and asked enter asker name first and asked 2nd";
 cin >> asker_two;
 cin >> asked_two;
 cout <<"ok 1 more question please choose an asker and asked as always asker first" >>endl;
 cin >> asker_three;
 cin >> asked_three;
 cout <<"ok time for extra question time if anyone wants to ask anyone go and ask as told always">>endl;
 cin >> asker_four;
 cin >> asked_four;
 cout <<"voting time everyone vote someone right now and click enter to continue">>endl;
 temp.cin.get();
 cout <<"and ....... is out of the category click enter to reveal">>endl;
 temp.cin.get();
 cout << "its "<<players[x]<<"gg";
                                         }
 }
 
 
 

    return 0;
    
}

2 Answers

+1 vote
answered Apr 24, 2023 by Peter Minarik (86,240 points)
cout <<"ok 1 more question please choose an asker and asked as always asker first" >>endl;

The right operator for cout is <<, not >> before endl.

temp.cin.get();

What you should do is this:

temp = cin.get();
0 votes
answered Sep 9, 2023 by Ananya K.J (300 points)
Its a syntax error of equal operator
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...