i needa make 2 functions both in the programing language C the first is a counte
ID: 3704383 • Letter: I
Question
i needa make 2 functions
both in the programing language C
the first is a counter that counts how many times my user has inputted an incorrect answer for my code.
a generic counter would also work.
// print out either a snowpal or just a number, indicating how many incorrect guesses the user has made
// Let's start with 10 incorrect guesses allowed
. After each incorrect guess, the wrong guesses count increments
void printSnowpal( int wrongGuesses );
the second is function gets a random number which is equal to the number of words from my variable listSize.
this function merely generates a random number for me using the prototype below
// function to randomly select a word from our list
// listSize is how large our word array is
// return value will be between 0 to listSize
int randWord( int listSize );
Explanation / Answer
The c functions would be
int randWord( int listSize )
{
return rand()%listSize;
//include stdlib.h for rand() function
}
void printSnowpal( int wrongGuesses )
{
if(wrongGuesses>10)
printf("Snowpal ");
else
printf("%d ",wrongGuesses);
}
Do give a thumbs up and in case there are doubts leave a comment.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.