Below is a C homework, but if you just want a C online tutor then we can do that for you as well.

Hangman

Download the letterGame.exe file and letterList.txt file to play a few rounds of the game

  1. create a project and name the source code letterGame.c
  2. use the sample program1Outline as a guide, copy/ paste into your project source code
  3. copy/paste the function prototypes from the assignment into your source code and set up the function defintions
  4. set numGames to a small number (Just to test the connection to the file and the loop, later you
    will ask the user how many games)
  5. go to the assignment and save letterList.txt into the same directory as letterGame.c (remember to
    use your Z drive on portal.eng.fau.edu)
  6. declare a file pointer variable, connect to the input file and use fscanf to read the letters one by
    one from the file and print onto the screen (should read letters from the file)
  7. use printf statements to see the letters from the file print onto the screen
  8. write the function defintion and function call for rules function
  9. Get user input on how many games they wish to Play and update the numGames variable with
    user input (A function is not required here, but you may add a function)
  10. Write the function call to GuessTheLetter, passing the the solution letter from the file
  11. Again use printf statements inside the GuessTheLetter function to see that the letter was passed to
    the function and is lowercase
  12. write the function defintion and function call to the GetTheGuess function call the function from
    inside the while loop of the GuessTheLetter functionAgain use printf statements see the letter is
    lowercase
  13. write the function defintion and function call to the CompareLetters function, passing it both the
    guess and the solution use if/ else if/ else conditions to compare the letter and the guess and give feedback
    to the user, this function will return a 1 if the solution and guess match and a 0 if they do not match
  14. Add conditions in the GuessTheLetter function AFTER the END OF THE WHILE loop to test the
    variable win, if it is a 0 the user did not win, if it is a 1, the user won that round, let the user know if they
    won or lost.

Topics: printf, scanf, file input, user defined function, and conditions (if/else, switch) and loops

Synopsis: You will code a C program that is a letter guessing game. The user can pick
between 1-8 games to play. The program will read the letter from an input file for each game.
The user will try to guess the letter and has 1-8 tries to guess it correctly. After which, the
game ends and the next one begins.

Instructions:

  • Write a program that reads letters from a file called “letterList.txt”.
  • Your program will ask the user to enter the number of games they wish to play (1 to 8)
  • Your program will open the letterList.txt file read in one character at a time and repeat
    this for the number of games the user wants to play.
  • For this assignment the test file will contain at least 8 letters, uppercase OR lowercase
  • In your program you will change each letter (solution and guess) to lowercase
    • Use the function tolower in #include
  • When the number of games has been played, the program will end
  • A sample of an input file that you can use to test your program is included with the
    assignment.
  • A preprocessor directive must be used to define the maximum number of guesses as 5
  • If the player has used up all of their guesses, a message that the game is over should
    be displayed along with the letter they were trying to guess.
  • You must have at least 4 user defined functions as follows:
    • No modifications may be made the to functions
      #define _CRT_SECURE_NO_WARNINGS
      #include <stdio.h>
      #include <ctype.h>
      #define MAXGUESSES 5
      //this function provides instructions to the user on how to play the game
      void GameRules();
      //this function runs one game. 
      //input: character from the file, void return type
      //all other functions to Play one round of a game 
      //are called from within the GuessTheLetter function
      void GuessTheLetter(char);
      //this function prompts the player to make a guess and returns that guess
      //this function is called from inside the GuessTheLetter( ) function described above
      char GetTheGuess();
      //this function takes two arguments, the guess from the player 
      //and the solution letter from the file. 
      //The function returns 1 if the guess matches the solution and returns a 0 if they do not match
      //This function also lets the user know if the guess comes alphabetically before or after the answer 
      int CompareLetters(char, char);

Additional Requirements:

  • Use function prototypes.
  • Write comments for each function that will appear in the file before each
    prototype and again before each function definition.
  • Be sure to comment your code adequately.
  • Be sure to indent properly. Check your textbook and lecture code examples to see how
    it should be done.
  • Use meaningful variable names

Sample Program Output:

Welcome to the Letter Guessing Game
First, you will enter the number of games you want to play (1 - 8
games)
For each game you will have 5 chances to guess each letter
Let's begin:
How many games? (1 to 8) 2
************************************
Ready to play game 1
----------------------------------------
Getting guess number 1
Enter a guess: w
The solution comes before your guess ( w )
----------------------------------------
Getting guess number 2
Enter a guess: t
The solution comes before your guess ( t )
----------------------------------------
Getting guess number 3
Enter a guess: S
The solution comes before your guess ( s )
----------------------------------------
Getting guess number 4
Enter a guess: H
The solution comes before your guess ( h )
----------------------------------------
Getting guess number 5
Enter a guess: f
The solution comes before your guess ( f )
SORRY, you did not win this round
The letter was d
Ready to play game 2
----------------------------------------
Getting guess number 1
Enter a guess: a
The solution comes after your guess ( a )
----------------------------------------
Getting guess number 2
Enter a guess: B
The solution and the guess are the same ( b )
And you Won !!!
Thank you for Playing the letter guess game

You should find a sample C homework, that indicates the quality of the work we are able to do for you.

program1Outline.c

//add name , date, and description here
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define MAXGUESSES 5
//paste all the function prototypes here
//with the comments

int main()
{
    //declare additional variables
    //declare FILE pointer
    int numGames, i = 0;
    char letter;//letter from file

    //display game rules
    //Ask and get number of games to play
    //connect to the file HINT: use fopen
    //this for loop will allow the player to play more than one game
    //without recompiling

    for (i = 0; i < numGames; i++)
    {
        //get a solution letter from file - use fscanf
        //change the solution to lowercase
        //print the solution back onto the screen to test
        //call the GuessTheLetter function and pass it the solution
    }
    //close file pointer
    return 0;
}

//this function runs one game. 
//input: character from the file, void return type
//all other functions to Play one round of a game 
//are called from within the GuessTheLetter function
//this function lets the user know if they have won or lost the game
void GuessTheLetter(char solution)
{
    int win = 0;
    int numGuesses = 0;
    //declare additional variables

    while (numGuesses < MAXGUESSES && win == 0)
    {
        //get a guess from the user  by calling the GetTheGuess function
        //change the guess to lowercase
            //win = call the function to compare the guess with the solution
        numGuesses++;//count the number of guesses so far
    }
    //use conditions to let the user know if they won or lost the round of the game
}

Solution

For all your C project help that you need, you won’t find a better place.

letterGame.c

//add name , date, and description here
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define MAXGUESSES 5

//paste all the function prototypes here
//with the comments
/*
* Display Game Rule
*/
void GameRules();

/*
* Function runs one game.
* Input character from the file, void return type all other functions to play one round of a game are called within the GuessTheLetter function
*/
void GuessTheLetter(char);

/*
* Function prompts the user to make a guess and returns that guess.
*/
char GetTheGuess();

/*
* Function take two arguments, the guess from the player and the solution letter from the file.
* Return 1 if the guess matches the solution
* Return 0 if they not match.
*/
int CompareLetters(char, char);

/*
* Print character  in loop
*/
void printCharacter();

int main()
{
    //declare additional variables
    //declare FILE pointer
    int numGames, i = 0;
    FILE * input;
    char solution;
    char letter;    //letter from file
    char guess;

    //display game rules
    GameRules();

    //Ask and get number of games to play
    printf("\nHow many games? (1 to 8) ");
    scanf(" %d", &numGames);
    printCharacter('*');
    //connect to the file HINT: use fopen
    input = fopen("letterList.txt", "r");
    //this for loop will allow the player to play more than one game
    //without recompiling
    for (i = 0; i < numGames; i++)
    {
        printf("\nReady to play game %d\n", i + 1);

        //get a solution letter from file - use fscanf      
        fscanf(input, "%c\n", &letter);

        //change the solution to lowercase
        solution = tolower(letter);

        //print the solution back onto the screen to test       
        //printf("\nThe letter is %c\n", solution);
        //call the GuessTheLetter function and pass it the solution
        GuessTheLetter(solution);
    }

    //close file pointer
    fclose(input);
    printf("Thank you for Playing the letter guess game\n");
    //getchar();
    system("pause");
    return 0;
}

void GameRules()
{
    printf("\nWelcome to the Letter Guessing Game.\n");
    printf(
        "\nFirst, you will enter the number of fames you want to play (1 - 8)\n");
    printf("\nFor each game, you will have 5 chances to guess each letter\n");
    printf("\nLet's begin! \n");    
}

//this function runs one game.
//input: character from the file, void return type
//all other functions to Play one round of a game
//are called from within the GuessTheLetter function
//this function lets the user know if they have won or lost the game
void GuessTheLetter(char solution)
{
    int win = 0;
    int numGuesses = 0;
    //declare additional variables
    char guess;
    char letter;

    while (numGuesses < MAXGUESSES && win == 0)
    {
        printCharacter('-');
        printf("Getting guess number %d\n", numGuesses + 1);
        //get a guess from the user  by calling the GetTheGuess function
        //change the guess to lowercase
        guess = GetTheGuess();

        //win = call the function to compare the guess with the solution
        win = CompareLetters(tolower(guess), solution);
        if (win == 0)
            printf("\nThe solution comes before your guess (%c)\n", tolower(guess));
        else
        {
            printf("The solution and the guess are the same (%c)\n", solution);
            printf("And you Won !!!\n");
        }
        numGuesses++;           //count the number of guesses so far
    }
    //use conditions to let the user know if they won or lost the round of the game
    if (numGuesses >= MAXGUESSES)
    {
        printf("\nSORRY, you did not win this round\n");
        printf("The letter was %c", solution);
    }
}

//This function get a letter from user
char GetTheGuess()
{
    char guess;
    printf("\nEnter a guess: ");
    scanf(" %c", &guess);
    return guess;
}

//This function compares the user letter with the letter from file.
int CompareLetters(char guess, char solution)
{
    if (guess == solution)
    {       
        return 1;
    }
    else
    {
        return 0;
    }
    return 0;
}

//This function prints stars just because.
void printCharacter(char character )
{
    for (int i = 0; i < 30; i++)
    {
        printf("%c ", character);
    }
    printf("\n");
}

Here is an example C assignment, that demonstrates the sort of C project help we can deliver.

letterList.txt

d
B
G
w
Q
t
r
Y
u
X

Index:

Don’t rely on your friends to help you with your C assignment help as copying from them may lead to you both getting in trouble.