Johhn
Johhn
Coimbatore - 641010
December-2023
By
NAME:JESHO JOHN S
REGISTER NO:71382304021
First Year B.E (ECE)
i|Pa g e
APPROVAL AND DECLARATION
This project report titled HANG MAN GAME PROGRAM USING C LANGUAGE was
prepared andsubmitted by JESHO JOHN (71382304021) and has been found satisfactory in terms of scope,
quality and done the presentation as partial fulfillment of the requirement for the Bachelor of engineering
(SRIT).
Project Supervisor
Assistant Professor
2|P ag e
Table of contents Pg.no
TABLE OF CONTENTS 3
ABSTRACT 4
LIST OF FIGURES 5
CHAPTER 1 INTRODUCTION 6
8
CHAPTER 2 METHODOLOGY
24
CHAPTER 3 EXPECTED RESULTS AND OUTPUT
25
CHAPTER 4 CONCLUSION
3|P ag e
HANG MAN GAME USING C LANGUAGE
ABSTRACT
The Hangman game represents a classic word-guessing game that has entertained and challenged
players for generations. In this traditional pen-and-paper game, or its digital adaptations, players
attempt to guess a hidden word by suggesting letters within a specified number of attempts while
The digital version of Hangman is a popular and engaging application that brings this timeless game
to life in a digital format. Developed with user-friendly interfaces and interactive elements, the
Hangman game fosters entertainment and cognitive engagement among players of all ages.
The essence of the Hangman game lies in its simplicity and yet its ability to test and enhance
vocabulary, word recognition, and deductive reasoning skills. Players are presented with a series of
dashes representing letters of an unknown word and must strategically guess individual letters to
Developed through programming languages like Python, JavaScript, or others, the Hangman game
predefined list, managing user inputs for letter guesses, updating the display with correct guesses,
4|P ag e
List of Figures
Figure No Page no
5|P ag e
CHAPTER -1
INTRODUCTION
The Hangman game stands as a timeless and engaging word puzzle that has entertained people of all ages for
decades. Its straightforward yet captivating gameplay revolves around word guessing, challenging players to
decipher a hidden word by guessing individual letters while avoiding the drawing of a complete hangman
figure.
Originating as a pen-and-paper pastime, the Hangman game has seamlessly transitioned into digital formats,
offering an interactive and immersive experience to players across various platforms. Through its simplicity
and yet intricate design, the game not only provides entertainment but also serves as a stimulating exercise for
In the digital realm, the Hangman game is brought to life through programming languages such as Python,
JavaScript,and others. Its digital adaptation involves creating a dynamic interface that allows players to
interactively guess letters, uncover parts of the hidden word, and strategically navigate the challenge of
The allure of the Hangman game lies in its simplicity – players are presented with a series of dashes
representing theletters of an unknown word and must guess individual letters to fill in the blanks, progressively
revealing the concealed word. However, incorrect guesses result in the gradual drawing of a hangman figure,
6|P ag e
FLOW CHART:
7|P ag e
CHAPTER – 2
METHODOLOGY
Set up data structures to store the words to be guessed and track game progress:Use arrays or linked
Create structures or arrays to manage the state of the game, such as the hidden word, guessed
Word Selection:
Implement a function to randomly select a word from the predefined list. Retrieve and store the
Show placeholders (underscores or dashes) for each letter in the word to be guessed.
Display relevant information such as the number of attempts left and any initial hangman figure
representation.
Implement a function to handle user input for letter guesses. Validate the input to ensure it is a valid
letter.
Check the guessed letter against the hidden word and update the display accordingly (revealing
correct letters,
8|P ag e
updating the hangman figure for incorrect guesses).
Develop the game logic to track progress and determine game outcomes.
Implement mechanisms to track correct and incorrect guesses, manage attempts left, and decide when
Design functions to update the display after each guess, reflecting the current state of the game. Show
the updated hangman figure and reveal correctly guessed letters in the hidden word.
Continuously update the interface to provide feedback to the player on their progress.
Implement robust error handling to manage unexpected inputs or invalid game states.
Validate user inputs to ensure they conform to the game's requirements (e.g., single letter guesses,
avoidingrepetition of guesses).
Refine the user interface to enhance user experience and provide clear instructions and feedback.
Conduct thorough testing of the game to identify and rectify bugs or issues.
Test different scenarios, including various word lengths, correct and incorrect guesses, and game-
endingconditions.
9|P ag e
2.1 EXISTING TECHNIQUE
design an interactive and engaging word-guessing experience. The process encompasses several
key steps that bring together data handling, user interface development, game logic, and error
handling.
Fundamentally, the game begins by establishing data structures to manage essential components
such as the word list and game state. Employing arrays or structures helps store words for the
game and track the evolving game progress, including the hidden word and the user's guessed
letters.
An integral aspect is designing an intuitive user interface that renders the Hangman ASCII art
and presents an interactive display for guessing letters. This interface displays placeholders for
the unknown letters of the word and visually represents the hangman's progression based on
The game's core functionality revolves around user input for guessing letters and the subsequent
processing of these guesses. It involves validating the input for correctness, comparing the
guessed letters against the hidden word, and dynamically updating the display to reveal correct
guesses while incrementally showcasing the hangman figure for incorrect attempts.
Additionally, robust game logic determines the win/loss conditions based on the accuracy of the
guesses and the remaining attempts. Implementing error-handling mechanisms ensures a smooth
12 | P a g e
gameplay experience by managing unexpected inputs and invalid states.
The modularity of functions and a structured code layout aid in maintaining an organized and
comprehensible codebase. Dividing tasks into smaller functions facilitates easier debugging,
operations, and streamlining loops and conditional statements. Thorough testing across diverse
scenarios guarantees the game's functionality, identifying and resolving potential bugs or
inconsistencies.
Documenting the code with comprehensive comments and user guidelines enriches the
development process by enhancing readability and providing clarity for future reference,
This iterative methodology enables the creation of a fully functional Hangman game in C,
amalgamating programming intricacies and game design elements to deliver an entertaining and
13 | P a g e
.2.1 SOFTWARE REQUIREMENTS
Certainly! Let's delve into the details of the software requirements for developing and
C Compiler:
GCC (GNU Compiler Collection): This open-source compiler is widely used for C
you might use MinGW (Minimalist GNU for Windows) to get GCC.
Microsoft Visual C++: This compiler is provided by Microsoft and is often used for
Code::Blocks: A free and open-source IDE that supports multiple compilers, including GCC.
Visual Studio Code: While not a traditional IDE, Visual Studio Code is a highly
customizable and lightweight code editor that supports C/C++ development through
extensions.
Notepad++: A free and feature-rich text editor that is popular among developers.
Sublime Text: A sophisticated text editor known for its speed and versatility.
Operating System:
C is a cross-platform language, so you can develop and run your calculator program on
14 | P a g e
Terminal/Command Prompt (for Compilation and Execution):
Git: A distributed version control system that allows you to track changes in your codebase.
Install GCC:
Windows: Download and install MinGW, and ensure that the GCC compiler is selected
during installation.
Linux: Use your distribution's package manager to install the build-essential package, which
includes GCC.
Windows/Linux/macOS: Download Visual Studio Code from the official website and
Install Extensions: Open Visual Studio Code, go to the Extensions view (Ctrl+Shift+X), and
15 | P a g e
Open Visual Studio Code, create a new file, write your C code, and save it with a .c extension
(e.g., calculator.c).
Open a terminal within Visual Studio Code or use your system's terminal.
Compile your code using the gcc command (e.g., gcc calculator.c -o calculator).
By following these steps and meeting the specified software requirements, you can
successfully develop and execute a Calculator Program using the C language. Adjustments
The provided C program is an implementation of a hang man game that allows users to
perform various operations. Let's break down the key components and functionalities:
Header Files:
The program includes standard C library header files such as <stdio.h>, <conio.h>, and
<stdlib.h>. These headers provide functions for input/output, mathematical operations, and
program control.
Function Declarations:
The program declares several functions at the beginning, each corresponding to a specific
arithmetic operation .
16 | P a g e
Function declarations ensure that the compiler knows about these functions before they are
Main Function:
The main function is the entry point of the program. It uses a do-while loop to repeatedly
display a menu of operations and perform the selected operation until the user chooses to exit
(option 7).
Switch Statement:
The switch statement is used to execute a block of code based on the value of the variable op,
representing the user's choice. Depending on the user's input, it calls the corresponding
17 | P a g e
ALGORITHM:
Create arrays or structures to store the word list and manage game state. Define variables for the
hidden word, guessed letters, attempts left, etc. Load Word List:
Randomly select a word from the word list for the current game session
.
Store the chosen word as the hidden word to be guessed.
Display placeholders (underscores or dashes) for each letter in the hidden word.
Game Loop:
Start a loop for the game to continue until a win or loss condition is met.Display the current state
Check if the input is a valid single letter (not a digit, symbol, or multiple characters). Ensure the
Compare the guessed letter against the hidden word.If the letter matches a letter in the word:
Update the hangman figure display to show parts of the hangman.Decrease the attempts left.
Check if all letters of the hidden word have been guessed.If yes, display a winning message.
If attempts reach zero, display a losing message and reveal the hidden word.
18 | P a g e
End Game or Play Again:
Validate user inputs rigorously to prevent errors and ensure smooth gameplay.
19 | P a g e
EXPLANATION:
The Hangman game stands as a popular and enjoyable word puzzle that challenges players to
guess a hiddenword by suggesting individual letters within a limited number of attempts. Its
straightforward yet captivating gameplay has made it a timeless pastime for people of all ages,
In the digital realm, the Hangman game takes on various forms, including applications and
software developed using programming languages like C. The essence of the game remains
consistent: players aim to decipher an unknown word by guessing its letters while avoiding the
At its core, the game starts by selecting a word, which remains concealed from the player. The
player attempts to unravel this word by suggesting letters, one at a time. Correct guesses reveal
the positions of thecorrectly guessed letters within the word, while incorrect guesses result in the
The visual representation of the hangman's progression, often depicted as a gallows and an
incomplete figure, adds an element of suspense and urgency. Players strive to guess the word
20 | P a g e
PROGRAM:
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
#include <string.h>
#define WORDS 10
#define WORDLEN 40
#define CHANCE 6
int i_rnd(int i) {
if (!srand_called) {
srand_called = true;
return rand() % i;
20 | P a g e
if((code - word + 2) % 3 == 1){
*decrypt = '\0';
return toFree;
switch(mistakes) {
default: break;
printf("\t \n"
"\t| |\n"
"\t| %c %c\n"
"\t| %c%c%c\n"
"\t| %c %c\n"
"\t| \n"
21 | P a g e
"\t| ", body[0], body[1], body[2],
printf("\t");
printf("\n\n");
int main() {
printf("\n\t - All words are name of very popular Websites. eg. Google");
int id = i_rnd(WORDS);
22 | P a g e
char *word = decrypt(values[id]);
char falseWord[CHANCE];
char guess;
bool found;
char* win;
int mistakes = 0;
do {
found = false;
printf("\n\n");
printBody(mistakes, body);
printf("\n\n");
if(mistakes == 0) printf("None\n");
printf("%c", falseWord[i]);
printf("\n\n");
printWord(guessed, len);
23 | P a g e
printf("\tGive me a alphabet in lower case : ");
if(word[i] == guess) {
found = true;
guessed[i] = guess;
if(!found) {
falseWord[mistakes] = guess;
mistakes += 1;
if(win == NULL) {
printf("\n");
printWord(guessed, len);
} else {
printf("\n");
printBody(mistakes, body);
free(body);
24 | P a g e
free(guessed);
return 0;
25 | P a g e
CHAPTER – 3
24 | P a g e
25 | P a g e
26 | P a g e
CHAPTER – 4
CONCLUSION
In conclusion, the Hangman game epitomizes a timeless blend of simplicity, challenge, and
entertainment, captivating players with its intriguing word-guessing mechanics. From its origins as a
pen-and-paper pastime to its digital adaptations using programming languages like C, Hangman
continues to enchant players of all ages, offering an engaging blend offun and mental stimulation.
This classic game's allure lies in its straightforward yet immersive gameplay, challenging players to
unravel a hidden word through strategic letter guesses while avoiding the completion of the hangman
figure. Its interactive nature, accompanied by visual cues of the hangman's progression, fosters an
element of suspense, prompting players to exercise deductive reasoning and vocabulary skills in a
Moreover, the Hangman game extends beyond mere entertainment, serving as an educational tool
that enhances language proficiency, word association, and problem- solving abilities. Its ability to
engage players in a fun yet educational manner makes it a valuable resource for vocabulary
The digital adaptation of Hangman, often developed using programming languages like C,
underscores the fusion of technology and gameplay, creating an interactive user interface while
preserving the game's fundamental mechanics. This amalgamation brings to life the essence of
Hangman, offering players an immersive experience while navigating the challenges of guessing the
hidden word.
28 | P a g e
SRI RAMAKRISHNA INSTITUTE OF TECHNOLOGY, COIMBATORE-10
(Approved by AICTE, New Delhi – Affiliated to Anna University, Chennai)
(Accredited by NAAC with ‘A’ Grade and All UG Engineering Programmes are
Accredited by NBA)
I SEM ECE
2 Presentation 35
3 Demo 30
4 Total 100
(A.Jayasmruthi)
Course Coordinator
27 | P a g e