Source code:-
- -----------------
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX_GUESSES 6
int main()
{
char guess,choice;
char visible_WordString[100];
char WordString[255]=" ";
char hint[255]=" ";
int num_letters=
0,i=0,count=0,tries=0,num_vis_chars=0;
int
correct_guesses=0,correct_flag=0,repeat_flag=0;
char incorrect_letters[255]=" ";
do
{
memset(WordString,0,sizeof(WordString));
memset(hint,0,sizeof(hint));
printf("\nGuess
the WordString: ");
gets(WordString);
printf("\nGive
hint:");
gets(hint);
num_letters =
strlen(WordString );
/* displays
correct guesses */
for(i=0;i<num_letters;i++ )
{
visible_WordString[i]='-';
}
visible_WordString[num_letters] = '\0';
printf("\nWelocme to the
HANGMAN" );
printf("\nHINT:
%s", hint);
while(
tries<MAX_GUESSES)
{
printf("\nWordString: %s\n", visible_WordString
);
printf("\nIncorrect Guesses: %s\n",
incorrect_letters );
printf("\nGuess a letter ");
scanf("%c", &guess );
for(count= 0; count < num_letters; count++
)
if(guess == visible_WordString[count] || guess
== incorrect_letters[count] )
{
repeat_flag = 1;
correct_flag = 1;
break;
}
if( repeat_flag == 0 )
for( count = 0; count < num_letters; count++ )
{
if( guess == WordString[count] )
{
visible_WordString[count] =
guess;
correct_guesses++;
if( correct_guesses ==
num_letters )
{
printf("\nCONGRATULATIONS!
You guessed the Word!" );
printf("\nWord: %s\n",
visible_WordString );
exit( 0 );
}
correct_flag = 1;
}
}
if( correct_flag == 0 )
{
incorrect_letters[tries] = guess;
tries++;
}
repeat_flag = 0;
correct_flag = 0;
printf("\nWelocme to the HANGMAN");
printf("\nHINT: %s", hint );
}
printf("\nYou
did not guess the word." );
printf("\nWORD:
%s\n", visible_WordString );
printf("\nWant
to play Again press y for yes 'n' for No");
choice=getchar();
}while(choice=='y'||choice=='Y');
return 0;
}
Sample Output:-
--------------------------------
Guess the WordString: hangman
Give hint:h
Welocme to the HANGMAN
HINT: h
WordString: -------
Incorrect Guesses:
Guess a letter g
Welocme to the HANGMAN
HINT: h
WordString: ---g---
Incorrect Guesses:
Guess a letter
Welocme to the HANGMAN
HINT: h
WordString: ---g---
Incorrect Guesses:
Guess a letter m
Welocme to the HANGMAN
HINT: h
WordString: ---gm--
Incorrect Guesses:
Guess a letter
Welocme to the HANGMAN
HINT: h
WordString: ---gm--
Incorrect Guesses:
Guess a letter a
Welocme to the HANGMAN
HINT: h
WordString: -a-gma-
Incorrect Guesses:
Guess a letter
Welocme to the HANGMAN
HINT: h
WordString: -a-gma-
Incorrect Guesses:
Guess a letter n
Welocme to the HANGMAN
HINT: h
WordString: -angman
Incorrect Guesses:
Guess a letter
Welocme to the HANGMAN
HINT: h
WordString: -angman
Incorrect Guesses:
Guess a letter h
CONGRATULATIONS! You guessed the Word!
Word: hangman
--------------------------------
Process exited after 23.48 seconds with return value 0
Press any key to continue . . .
Please help with this Intro to programming in C assignment! Intro to Programming in C-Large Program...
This is for C programming: You will be given files in the following format: n word1 word2 word3 word4 The first line of the file will be a single integer value n. The integer n will denote the number of words contained within the file. Use this number to initialize an array. Each word will then appear on the next n lines. You can assume that no word is longer than 30 characters. The game will use these words as...
For a C program hangman game: Create the function int play_game [play_game ( Game *g )] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) (Also the link to program files (hangman.h and library file) is below the existing code section. You can use that to check if the code works) What int play_game needs to do mostly involves calling other functions you've already...
C++ Hangman (game) In this project, you are required to implement a program that can play the hangman game with the user. The hangman game is described in https://en.wikipedia.org/wiki/Hangman_(game) . Your program should support the following functionality: - Randomly select a word from a dictionary -- this dictionary should be stored in an ASCII text file (the format is up to you). The program then provides the information about the number of letters in this word for the user to...
C++ programming Submit assignment to Blackboard by the midnight on the due date listed above. (Verify if your submission is completed.) The only people you are to discuss this project with are myself and the CS Department tutor. Duplicate code, if discovered, will result in a 0 grade. Your source file(s) should follow the Computer Science Coding Standards (available at the Computer Science Homepage) including proper indenting and spacing 1 Overview program, you will play a game of hangman. In...
I have to use java programs using netbeans. this course is introduction to java programming so i have to write it in a simple way using till chapter 6 (arrays) you can use (loops , methods , arrays) You will implement a menu-based system for Hangman Game. Hangman is a popular game that allows one player to choose a word and another player to guess it one letter at a time. Implement your system to perform the following tasks: Design...
Overview In this exercise you are going to recreate the classic game of hangman. Your program will randomly pick from a pool of words for the user who will guess letters in order to figure out the word. The user will have a limited number of wrong guesses to complete the puzzle or lose the round. Though if the user answers before running out of wrong answers, they win. Requirements Rules The program will use 10 to 15 words as...
Need help with this C program? I cannot get it to compile. I have to use Microsoft Studio compiler for my course. It's a word game style program and I can't figure out where the issue is. \* Program *\ // Michael Paul Laessig, 07 / 17 / 2019. /*COP2220 Second Large Program (LargeProg2.c).*/ #define _CRT_SECURE_NO_DEPRECATE //Include the following libraries in the preprocessor directives: stdio.h, string.h, ctype.h #include <stdio.h> /*printf, scanf definitions*/ #include <string.h> /*stings definitions*/ #include <ctype.h> /*toupper, tolower...
Please write a C# program that where a player will play a guessing game with the range of 1-100. Each time the play guesses a number, and it is not correct the program should indicate if the number is more or less than what the player guessed. The play should be able to guess until the correct number has been guessed. If an invalid number is entered, such as: 1.24 (real number), or asd (string). The program should tell user...
Create the game hangman using c code: Program description In the game of hangman, one player picks a word, and the other player has to try to guess what the word is by selecting one letter at a time. If they select a correct letter, all occurrences of the letter are shown. If no letter shows up, they use up one of their turns. The player is allowed to use no more than 10 incorrect turns to guess what the...
JAVA Hangman Your game should have a list of at least ten phrases of your choosing.The game chooses a random phrase from the list. This is the phrase the player tries to guess. The phrase is hidden-- all letters are replaced with asterisks. Spaces and punctuation are left unhidden. So if the phrase is "Joe Programmer", the initial partially hidden phrase is: *** ********** The user guesses a letter. All occurrences of the letter in the phrase are replaced in...