// my problem is in the playerscore and computerscore always gives me 0 or 1 
// i cant know who finally won plz i need ur help 
//at the end of the program it should gives me the score of computer and the user out of 5 of the total rounds



#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
void toss(int & x)

    //0=heads 1=tails
    x=rand()%2;

int result(int a, int b, int c)
{
    int count=0;
    if(a==0)
        count=count+1;
    if(b==0)
        count=count+1;
    if(c==0)
        count=count+1;
    return count;
}
int main ()
{
    srand(time(0));
    for(int i=0;i<20;i++)
    {
        cout<<"GAME212"<<endl;
        system("CLS");
    }
    int playagain=1;
    do
    {
        int play;
        cout<<"Enter 1 to play or 0 to quit: ";
        cin>>play;
        if(play==0)
            break;
        if(play==1)
        {   int turn;
            for(turn=1;turn<=10;turn++)
            {
                int coin1, coin2, coin3, times, playerscore=0, computerscore=0, playerwins=0, computerwins=0;
                if(turn%2==1)
                {
                    cout<<"\n\nHow many times do you want to toss the three coins together?";
                    cin>>times;
                    playerwins=0;
                    computerwins=0;
                    for(int j=1;j<=times && playerscore<5 && computerscore<5;j++)
                    {
                        toss(coin1);
                        toss(coin2);
                        toss(coin3);
                        if(coin1==0)
                            cout<<"\nCoin1: Heads"<<endl;
                        else
                            cout<<"\nCoin1: Tails"<<endl;
                        if(coin2==0)
                            cout<<"Coin2: Heads"<<endl;
                        else
                            cout<<"Coin2: Tails"<<endl;
                        if(coin3==0)
                            cout<<"Coin3: Heads\n"<<endl;
                        else
                            cout<<"Coin3: Tails\n"<<endl;
                        int countheads = result(coin1,coin2,coin3);
                        if(countheads>1)
                        {
                            playerwins=playerwins+1;
                            if(playerwins>times/2)
                                playerscore=playerscore+1;
                            if(computerwins>times/2)
                                computerscore=computerscore+1;
                            cout<<"You win this round"<<endl;
                            cout<<"Your round score: "<<playerwins<<"/"<<times<<endl;
                            cout<<"Computer round score: "<<computerwins<<"/"<<times<<endl;
                            cout<<"Your Score: "<<playerscore<<"/5"<<endl;
                            cout<<"Computer Score: "<<computerscore<<"/5"<<endl;
                        }
                        else
                        {
                            computerwins=computerwins+1;
                            if(playerwins>times/2)
                                playerscore=playerscore+1;
                            if(computerwins>times/2)
                                computerscore=computerscore+1;
                            cout<<"You lose this round"<<endl;
                            cout<<"Your round score: "<<playerwins<<"/"<<times<<endl;
                            cout<<"Computer round score: "<<computerwins<<"/"<<times<<endl;
                            cout<<"Your Score: "<<playerscore<<"/5"<<endl;
                            cout<<"Computer Score: "<<computerscore<<"/5"<<endl;
                        }
                    }
                }
                if(turn%2==0)
                {
                    //I chose to give it a limit of 8 times to toss the coins because it would be rediculous to toss it 1000 times for example
                    times=rand()%8;
                    cout<<"\n\nThe computer chose to toss the three coins "<<times<<" times"<<endl;
                    playerwins=0;
                    computerwins=0;
                    for(int j=1;j<=times && playerscore<5 && computerscore<5;j++)
                    {
                        toss(coin1);
                        toss(coin2);
                        toss(coin3);
                        if(coin1==0)
                            cout<<"\nCoin1: Heads"<<endl;
                        else
                            cout<<"\nCoin1: Tails"<<endl;
                        if(coin2==0)
                            cout<<"Coin2: Heads"<<endl;
                        else
                            cout<<"Coin2: Tails"<<endl;
                        if(coin3==0)
                            cout<<"Coin3: Heads\n"<<endl;
                        else
                            cout<<"Coin3: Tails\n"<<endl;
                        int countheads = result(coin1,coin2,coin3);
                        if(countheads>1)
                        {
                            playerwins=playerwins+1;
                            if(playerwins>times/2)
                                playerscore=playerscore+1;
                            if(computerwins>times/2)
                                computerscore=computerscore+1;
                            cout<<"You win this round"<<endl;
                            cout<<"Your round score: "<<playerwins<<"/"<<times<<endl;
                            cout<<"Computer round score: "<<computerwins<<"/"<<times<<endl;
                            cout<<"Your Score: "<<playerscore<<"/5"<<endl;
                            cout<<"Computer Score: "<<computerscore<<"/5"<<endl;
                        }
                        else
                        {
                            cout<<"You lose this round"<<endl;
                            computerwins=computerwins+1;
                            if(playerwins>times/2)
                                playerscore=playerscore+1;
                            if(computerwins>times/2)
                                computerscore=computerscore+1;
                            cout<<"Your round score: "<<playerwins<<"/"<<times<<endl;
                            cout<<"Computer round score: "<<computerwins<<"/"<<times<<endl;
                            cout<<"Your Score: "<<playerscore<<"/5"<<endl;
                            cout<<"Computer Score: "<<computerscore<<"/5"<<endl;
                        }
                    }

                }
            }
        cout<<"Enter 1 to play again or 2 to exit: ";
        cin>>playagain;
        if(playagain==1);
        }
    }
    while(playagain==1);
    return 0;
}

You seem to be missing the opening brace here

void toss(int & x)//missing brace here
//0=heads 1=tails
x=rand()%2;

Actually, what is going on here?

void toss(int & x)
//0=heads 1=tails
x=rand()%2;
int result(int a, int b, int c)
{
...
}

oh no dude the problem is not with the {} i just forget to put them here
the question is :

Write a game called “GAME 212” played by a user versus the computer.
Computer moves should be identical to those of the human user’s moves but of course produced using a random pattern.

Opening Screen
The program should display a menu from which you chose to play or quit.
Display before the menu the name of the game and let it blink for few seconds.
After the end of each game you need to clear the screen and redisplay the menu.

The Game
Your game is a simulation of tossing a coin and it is formed of five turns for each player (a total of 10 turns).
You start with the human player than the computer player .
At the end of the gem, your program must indicate who the winner is.
In a turn, the program asks the player how many times he wants to toss the three coins together. For example,
In Turn 1 a player may chose to toss the coin twice while in turn 2 he may chose to toss the coin five times.
When the three coins are tossed and the player gets two heads and a tail this should be marked as a successful trial.
By the end of a player’s turn, if he had a successful trial count greater than half his chosen trial number then he
scores 1 point out of 5.
When it is the computer’s turn, let the program print out messages to indicate what the computer is doing.

You must have a least two functions. Make sure to use call-by-reference in one of those functions and also make sure that at least one of them returns back a value to main. Your functions should contain at least 5 lines of code.
You are not allowed to use global variables.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.