Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Greetings, I had tried so many different ways to fit my code to this instruction

ID: 3812023 • Letter: G

Question

Greetings, I had tried so many different ways to fit my code to this instructions for hangman game for programing in C. I hope someone could help me with assignment. thank you!! the instructions for the program are the following:

Hangman Outline
NOTE: this is not required, just possible suggestions, to use but can be helpful in organizing your programming assignment
//8 user-defined functions with meaningful names that perform the specified tasks:
A function that determines if the second array matches the first array.
int MatchIt(char wrd[], char guess[]); or void MatchIt(char wrd[], char guess[], int* isamatch);
//A function that determines if the player would like to play again.
char playAgain(); 0r void playAgain(char *playagn);
//A function that tells the user if they won or lost
void WinOrLose(int result);
A function that returns the index of the letter that the user has guessed or something else if the letter is not in the word.
int PlaceGuess(); Or void PlaceGuess(int *index);
//A function that displays the instructions on how to play the game.
void HowToPlay();
A function that displays the contents of a character array (not a string).
void DisplayArrayr(char wrd[ ]);
//A function that returns the letter that the user has guessed.
//A function that sets all of the characters in a word to the same case (upper or lower).
//A function that locates and places the selected letter where it belongs in the partial solution array.
//Two additional functions of your own choice.
Suggestions:
int SomethingUsefulLikeComparingScrambledWordToGuessedWord(char wrd[], char scramble[]);
void PlayOneGame( char wrd[]);
char GetLetter(); or void GetLetter(char* ltr);
int main()
{
//declare variables
//display instructions
//open file
do{
//get word from file
//play one game
do{
//Display scrambled word
//Display partial solution
//Ask player for a letter
//locate where letter appears in solution
//place letter in same location in partial solution
//display updated partial solution
//get user guess
//if correct = game over, loop ends
//if not correct
//update wrong guess count
//if guesses left repeat loop
//if no guesses left – game over- loop ends
}
//play again???
}while(wants to play);
return 0;
}
//Function Definitions

---------------------------------------------------------------------

sample output is:

WELCOME TO HANGMAN!
Please read the following instructions before you play.
-You will be presented with a word to be guessed
-Guess letters one at a time
-You can have up to six incorrect guesses
-The game will be OVER when you have guessed
all the letters in the word
or when you have guessed incorrectly SIX times.
HAVE FUN!
--------------------
Guess this word:
* * * * * *
letters guessed so far:
Enter a letter: f
your letter is NOT in the word!
You have 5 more guesses
* * * * * *
letters guessed so far: f
Enter a letter: i
your letter is in the word!
* i * * * *
letters guessed so far: f i
Enter a letter: p
your letter is in the word!
* i * p * *
letters guessed so far: f i p
Enter a letter: o
your letter is NOT in the word!
You have 4 more guesses
* i * p * *
letters guessed so far: f i p o
Enter a letter: m
your letter is in the word!
* i m p * *
letters guessed so far: f i p o m
Enter a letter: e
your letter is in the word!
* i m p * e
letters guessed so far: f i p o m e
Enter a letter: g
your letter is NOT in the word!
You have 3 more guesses
* i m p * e
letters guessed so far: f i p o m e g
Enter a letter: l
your letter is in the word!
* i m p l e
letters guessed so far: f i p o m e g l
Enter a letter: s
your letter is in the word!
s i m p l e
you won!!!!
Would you like to play again?
Enter Q to QUIT, anything else to continue
y
--------------------
Guess this word:

* * * *
letters guessed so far:
Enter a letter: g
your letter is NOT in the word!
You have 5 more guesses
* * * *
letters guessed so far: g
Enter a letter: e
your letter is in the word!
* * * e
letters guessed so far: g e
Enter a letter: j
your letter is NOT in the word!
You have 4 more guesses
* * * e
letters guessed so far: g e j
Enter a letter: o
your letter is NOT in the word!
You have 3 more guesses
* * * e
letters guessed so far: g e j o
Enter a letter: n
your letter is in the word!
n * * e
letters guessed so far: g e j o n
Enter a letter: m
your letter is NOT in the word!
You have 2 more guesses
n * * e

letters guessed so far: g e j o n m
Enter a letter: q
your letter is NOT in the word!
You have 1 more guesses
n * * e
letters guessed so far: g e j o n m q
Enter a letter: w
your letter is NOT in the word!
You have 0 more guesses
n * * e
you did not win- the word was nice
Would you like to play again?
Enter Q to QUIT, anything else to continue
q
Press any key to continue . . .

Explanation / Answer

#include<stdio.h>
#include <time.h>
int check_letter(char r[],char c,int n)
{
   int i;
   for(i=0;i<n;i++)
   {
       if(r[i]==c)return i;//if char found in string...returning index  
   }
   return -1;
  
}
void print_array(char a[],int n)
{
   int i;
   for(i=0;i<n;i++)
   {
       printf("%c",a[i]);  
   }
   printf(" ");
}
int main()
{
   int n;//random string length
   n = (rand()%10)+4;//length between 4 and 12
  
   char r[n];//random string
   char al[26];//character array
   char guessed_letters[n];//array to store guessed string
   int i;
   for(i=0;i<26;i++)
   {
       al[i] = (char)(i+97);//storing all aphabets...          
   }
   int l;
   for(i=0;i<n;i++)
   {
       l=rand()%26;
       guessed_letters[i]='*';//placing * means not guessed in guessed array
       r[i]=al[l];      
   }//random string generated...
  
   int guess=6,correct=0;
   //printing instructions..
   printf(" WELCOME TO HANGMAN! Please read the following instructions before you play. -You will be presented with a word to be guessed -Guess letters one at a time -You can have up to six incorrect guesses -The game will be OVER when you have guessed all the letters in the word or when you have guessed incorrectly SIX times. HAVE FUN!");
  
   printf("Guess this word: ");
   print_array(guessed_letters,n);
  
  
   char G[n+guess];
   int g=0,p;//variable to keep track of guessing
   //loop runs upto breaking condition meets..
   char c,d;
  
  
   while(guess!=0&&correct!=n)
   {
           printf("letters guessed so far:");
           print_array(G,g);
           printf("Enter a letter:");
           scanf("%c%c",&c,&d);
           G[g++]=c;//adding to guessed so far letters
           p=check_letter(r,c,n);//returns -1 if not found else returns chars position in string
           if(p==-1)//if not found
           {
               printf("your letter is NOT in the word! ");
               guess--;
              
               printf("you have %d more guesses ",guess);
              
              
           }
           else
           {
               printf("your letter is in the word! ");
               correct++;
           }
           guessed_letters[p]=c;//adding to guessed letters..
           print_array(guessed_letters,n);
                  
   }
   //printing result...
   if(correct!=n && guess==0)
   {
           printf(" you did not win- the word was ");
           print_array(r,n);
   }
   else
   {
             printf("s i m p l e you won!!!!");      
   }
  
   char Break;
   printf("Would you like to play again? Enter Q|q to QUIT, anything else to continue");
   scanf("%c",&Break);
   if(Break != 'Q' || Break != 'q')main();
   return 0;
}

ouput:-

WELCOME TO HANGMAN!
Please read the following instructions before you play.
-You will be presented with a word to be guessed
-Guess letters one at a time
-You can have up to six incorrect guesses
-The game will be OVER when you have guessed all the letters in the word
or when you have guessed incorrectly SIX times.
HAVE FUN!Guess this word:
*****
letters guessed so far:
Enter a letter:g
your letter is in the word!
**g**
letters guessed so far:g
Enter a letter:a
your letter is NOT in the word!
you have 5 more guesses
**g**
letters guessed so far:ga
Enter a letter:r
your letter is NOT in the word!
you have 4 more guesses
**g**
letters guessed so far:gar
Enter a letter:p
your letter is NOT in the word!
you have 3 more guesses
**g**
letters guessed so far:garp
Enter a letter:n
your letter is NOT in the word!
you have 2 more guesses
**g**
letters guessed so far:garpn
Enter a letter:w
your letter is NOT in the word!
you have 1 more guesses
**g**
letters guessed so far:garpnw
Enter a letter:a
your letter is NOT in the word!
you have 0 more guesses
**g**

you did not win- the word was hqghu
Would you like to play again?
Enter Q|q to QUIT, anything else to continue