Word guessing game

I need some help completing a word guessing game.

The functions names need to remain they way they are named. Inside the main CAN NOT be changed, only functions can be.

I'm stuck on the last one: number_right.

the function should take six characters. compare the 1st and 4th, and 2nd and 5th, and 3rd and 6th.
Then output which (if any) of those three pairs of characters match and should return either 0,1,2 or 3.

the game is asking to pick a three letter word (constonant vowel constonant). when you get one of the three right it will tell you which one is correct until you either run out of guesses or get the correct word. it will then ask if you would like to play again.

please also see if any of my other functions need any changes.

Thanks


#include<ctime>
#include <iostream>
#include<cstdlib>
using std::cout;
using std::cin;


int random( int x, int y );
void print_random_welcome_phrase();
void print_random_farewell();
char generate_random_consonant(char consonant1 );
char generate_random_vowel(char vowel );
char get_y_or_n();
int number_right(int consonant1,int vowel,int consonant2,int consonant1_guess,int vowel_guess,int consonant2_guess )

int main()

{
srand(time(0));
char consonant1, vowel, consonant2, consonant1_guess, vowel_guess, consonant2_guess, again;
int num_guesses, correct_letters;
const int MAX_GUESSES_ALLOWED = 10;
system("cls");
print_random_welcome_phrase();

do
{

num_guesses = 0;
generate_random_consonant( consonant1 );
generate_random_vowel( vowel );
generate_random_consonant( consonant2 );

do
{
cout << "\n\nTry to guess the three letter \"word\" I'm thinking of.\nThe word is in the form:"
<< " consonant vowel consonant.\n";
cin >> consonant1_guess >> vowel_guess >> consonant2_guess;
correct_letters = number_right( consonant1, vowel, consonant2, consonant1_guess, vowel_guess, consonant2_guess );
++num_guesses;
}while ( correct_letters != 3 && num_guesses < MAX_GUESSES_ALLOWED );

if ( correct_letters == 3 )
cout << "You guessed correctly in only " << num_guesses << " tries!.\n";
else
cout << "You ran out of guesses. The correct answer was " << consonant1 << vowel << consonant2 << ".\n";

cout << "Try again? (y or n) ";
again = get_y_or_n();
system("cls");
} while ( again == 'y' );

print_random_farewell();
system("pause");

return 0;
}


int random( int x, int y )
{
int low=x, high=y;
if ( x > y )
{
low = y;
high = x;
}
return rand() % (high - low + 1) + low;
}

void print_random_welcome_phrase()
{
switch (random(0,5))
{
case 0:
cout<< "hello.\n";
break;
case 1:
cout<< "hi. \n";
break;
case 2:
cout<< "how ah ya.\n";
break;
case 3:
cout<< "howdy.\n";
break;
case 4:
cout<< "Whatzzz up?\n";
break;
case 5:
cout<< "Yo.\n";
}
return;
}

void print_random_farewell()
{
switch (random(0,5))
{
case 0:
cout<< "See Ya.\n";
break;
case 1:
cout<< "So Long. \n";
break;
case 2:
cout<< "Catch ya later.\n";
break;
case 3:
cout<< "Bye.\n";
break;
case 4:
cout<< "Sayonara\n";
break;
case 5:
cout<< "Arrivederci.\n";
}
return;
}

char generate_random_vowel(char vowel)
{
srand(time(0));
char vowels[5] = {'a', 'e', 'i', 'o', 'u'};
return vowels[ rand() % 5];
}


char generate_random_consonant(char consonant1);
{
char consonant[19] = {'b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','z'};
return consonant[ rand() % 19];
}

char generate_random_consonant(char consonant2);
{
char consonant[19] = {'b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','z'};
return consonant[ rand() % 19];
}

char get_y_or_n();
{
char again = 'y';
while (again=='y')
again=tolower(again);
}

int number_right(int consonant1,int vowel,int consonant2, int consonant1_guess, int vowel_guess, int consonant2_guess )
{
int 1=a, 2=b, 3=c, 4=d, 5=e, 6=f;
if
return ;
}
Please, wrap it up in [code] tags, to make it more readable.

[code] *your code here* [/code ] (without the last white space)
1
2
3
4
5
6
7
8
9
10
11
12
int number_right(int consonant1,int vowel,int consonant2, int consonant1_guess, int vowel_guess, int consonant2_guess )
{
    int correctLetters = 0;
    if(consonant1 == consonant1_guess)
        correctLetters++;
    if(vowel == vowel_guess)
        correctLetters++;
    if(consonant2 == consonant2_guess)
        correctLetters++;

    return correctLetters;
}


This could do your number right function. You are using cin to check the user input. This might not be the best way because it needs the user to hit return to get input. Also you arent storing the getrandomconsonant & vowel functions anywhere.
Topic archived. No new replies allowed.