#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

i am having trouble putting functions in int main(). can someone show me how??? i want to put these function def. in int main()

int score_num(int& ns1,int& ns2,int& ns3, int& ns4, int& ns5, int& n6, char& gam_answ);
int roll_hold(int roll, int answer, int turn);
int turn_it_is(int& player1, int& player2);
void play_again(char letter);
void display_score(int curr_score);
int score_num(int& ns1,int& ns2,int& ns3, int& ns4, int& ns5, int& n6, char& gam_answ)
{
    int turn;
    while(char ns1=0)
    {
        cout << " next player " << ((turn % 2) ==1);
        cout << " please select r for roll and h for hold ";
        cin >> gam_answ ;
        gam_answ++;
    }
}
int roll_hold( int& answer)
{
    int which_Num;
    {
    if(answer=='r')
    {
        do
        {
        unsigned seed = time(0);
        srand(seed);
        which_Num = rand() % 7;
        }while(answer== 'r');
    }
    }
    {
        if (answer=='h')
        {
            do
            {
            system("pause");
            }while (answer=='h');
        }
    }
    return answer;
}
int turn_it_is(int& player1, int& player2)
{
    int go_again;
    cout <<  " it's your turn ";
    cin >> go_again;
    return go_again;
}
void play_again(char letter)
{
    cout << " Would you like to play agian?( press y or n): ";
    cin >> letter;

}
void display_score(int curr_score)
{
    int gam_answ;
    curr_score = gam_answ++;
}
int main ()
{
    int total_score, print_score, action, whose_turn, go_again;
    cout << "Race to 100 " << endl;
 return 0;
}

i want to put these function def. in int main()

int score_num(int& ns1,int& ns2,int& ns3, int& ns4, int& ns5, int& n6, char& gam_answ);
int roll_hold(int roll, int answer, int turn);
int turn_it_is(int& player1, int& player2);
void play_again(char letter);
void display_score(int curr_score);

here is int main()

int main ()
{
    int total_score, print_score, action, whose_turn, go_again;
    cout << "Race to 100 " << endl;
 return 0;
}

Those are called function prototypes and they don't go in main(). Put them near the top of the program unit, after all includes. Alternatively, you can create your own header file and put them there.

#include <iostream>
#include <string>
// other includes here

int score_num(int& ns1,int& ns2,int& ns3, int& ns4, int& ns5, int& n6, char& gam_answ);
int roll_hold(int roll, int answer, int turn);
int turn_it_is(int& player1, int& player2);
void play_again(char letter);
void display_score(int curr_score);

int main()
{
   // blabla
}

but i want to call the protypes n main. how will i do that?

replace the parameters with actual variable names

int main()
{
    int roll = 1;
    int answer = 2;
    int turn = 3;

    int x =  roll_hold(roll, answer, turn);
};

but when i do thAt

int main ()
{
    int total_score, print_score, action, whose_turn, go_again;
    cout << "Race to 100 " << endl;
    total_score = int score_num(int &ns1,int &ns2,int &ns3, int &ns4, int &ns5, int &n6, char gam_answ);
    action=int roll_hold(int& answer);
    whose_turn= int turn_it_is(int player1, int player2);
    go_again=void play_again( char letter);
    print_score= void display_score(int curr_score);

 return 0;
}

i get these 4 error codes and i dont know how to fix them :
error: expected `;' before "void"|
|error: expected primary-expression before "void"|
error: expected `;' before "int"|
|error: expected primary-expression before "int"|
and when i do it with out the void and int
i have to declare the variables in int main() ->>>?is that right?

FEEDBACK PLEASE- ok i got it but now the program is not reading the protypes to call all it is reading is my int main() body. so if i use set the protypes to variables i get the errors but if i dont the program runs but the program doesnt read anything but the int main() body. feedback please

#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int score_num(int& ns1,int& ns2,int& ns3, int& ns4, int& ns5, int& n6, char& gam_answ);
int roll_hold(int roll, int answer, int turn);
int turn_it_is(int& player1, int& player2);
void play_again(char letter);
void display_score(int curr_score);
int score_num(int& ns1,int& ns2,int& ns3, int& ns4, int& ns5, int& n6, char& gam_answ)
{
    int turn;
    while(char ns1=0)
    {
        cout << " next player " << ((turn % 2) ==1);
        cout << " please select r for roll and h for hold ";
        cin >> gam_answ ;
        gam_answ++;
    }
}
int roll_hold( int& answer)
{
    int which_Num;
    {
    if(answer=='r')
    {
        do
        {
        unsigned seed = time(0);
        srand(seed);
        which_Num = rand() % 7;
        }while(answer== 'r');
    }
    }
    {
        if (answer=='h')
        {
            do
            {
            system("pause");
            }while (answer=='h');
        }
    }
    return answer;
}
int turn_it_is(int& player1, int& player2)
{
    int go_again;
    cout <<  " it's your turn ";
    cin >> go_again;
    return go_again;
}
void play_again(char letter)
{
    cout << " Would you like to play agian?( press y or n): ";
    cin >> letter;
}
void display_score(int curr_score)
{
    int gam_answ;
    curr_score = gam_answ++;
}
int main ()
{
    int total_score, print_score, action, whose_turn, go_again;
    cout << "Race to 100 " << endl;
    int score_num(int& ns1,int& ns2,int& ns3, int& ns4, int& ns5, int& n6, char& gam_answ);
    int roll_hold( int& answer);
    int turn_it_is(int& player1, int& player2);
    void display_score(int curr_score);
    void play_again(char letter);
 return 0;
}

Compare your code with that of ancient dragon, and study them hard, you will soon see what he is doing differently to you. Until you have had a good hard look and have some sensible suggests please stop posting loads of code that means nothing.


Regards,
Chris

replace the parameters with actual variable names

int main()
{
    int roll = 1;
    int answer = 2;
    int turn = 3;

    int x =  roll_hold(roll, answer, turn);
};

i guess i dont understand when u say replace parmeters with actual varible names.

like this??
int main()
int play_again;
play_again=( function protypes)

You do realise that in the code posted Ancient Dragon had already made that replacement? Ancient Dragon posted compilable code all you have to do is copy what (s)he did and apply it to you other function calls.

As I have told you in one of your numerous other posts on this subject you need to get hold of an introductory programming text and read the first couple of chapters. You are lacking in some really fundamental concepts here, how to declare and use variables, how to declare and use functions, the purpose of main even! Whilst we could correct you problems you aren't going to learn anything by simply getting others to do it.

The amount of time you have spent posting to this site you could have read up on these subjects and fixed it yourself.

commented: Yes +4
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.