Programming
Programming
CALAMBA
Dalubhasaan ng Lungsod ng Calamba
FUNDAMENTALS OF PROGRAMMING
TITLE:
Valdez, Shelah L.
Page 1 of 15
TABLE OF CONTENTS
Page 2 of 15
INTRODUCTION
PURPOSE:
The purpose of this program “Find the Word – Guessing Game” is designed as an
interactive console-based game that provides an interactive and engaging experience where
players try to guess the correct positions of a hidden word under one of the three cups. The
program includes a scoring system to track the player's performance over multiple rounds,
motivating them to improve and achieve a higher score. Its primary goal is to challenge players
to deduce the correct position of a hidden “word” under one of the three cups through a series of
guesses. It offers immediate feedback on each guess and the option to play multiple rounds,
enhancing replay ability and keeping the player entertained. These game serve multi-purpose
including entertainment, as they provide a fun way to pass their time, Guessing games can help
the players to develop critical thinking, and can help the player to make decisions. Overall, this
program aims to combine challenge, fun, and interactivity in a simple yet enjoyable guessing
game.
SCOPE:
The scope of the game "Find the Word Guessing Game" is to provide a simple and
entertaining guessing experience for players of all ages, especially those who enjoy simple yet
fun games It is also suitable for beginners learning programming concepts such as loops, input
validation, and randomization. The game features interactive gameplay where players guess the
position of a hidden "word" under one of three cups, with randomized outcomes ensuring
Page 3 of 15
fairness and unpredictability. It includes input validation to handle incorrect entries and a scoring
system that tracks the player’s progress and performance across multiple rounds. Additionally,
the game offers the option to replay, enhancing its replayability and engagement. However, its
limitations include a lack of advanced graphics or complex logic, as it is a text-based program
designed primarily for learning and casual entertainment rather than immersive gaming, and
only a single player can play.
TOOL USED:
The programming language used is C Language. The tool used in this game is Coding C++.
The program includes <stdio.h> for input/output operations and uses rand() for random number
generation.
SYSTEM/PROGRAM OBJECTIVES
Objectives:
- To create an engaging game where users guess the correct position of a hidden word.
- To challenge players' ability to make logical guesses and think critically.
- Combine fun with a stimulating mental activity that challenges and entertains the players.
- To demonstrate the use of randomness and loops in C programming.
- To track user performance over multiple.
SYSTEM/PROGRAM FEATURES
Page 4 of 15
REQUIREMENTS
Hardware Requirements
Software Requirements:
Page 5 of 15
START
Wrong (0 point)
Correct (1point) (1,2,3)
v
Play Again
Y/N?
THANK YOU
END
Page 6 of 15
CODE IMPLEMENTATION
int main() {
int wordPosition, playerGuess, score = 0, rounds = 0; // Declare variables for the game's logic
do {
Page 7 of 15
do {
printf("\nEnter your guess (1, 2, or 3): "); // Prompt the user for a guess
printf("Invalid input! Please enter a number (1, 2, or 3).\n"); // For invalid input
while (getchar() != '\n'); // Clear the input buffer to remove invalid characters
} while (playerGuess < 1 || playerGuess > 3); // Repeat until a valid guess is entered
if (playerGuess == coinPosition) {
Page 8 of 15
} else {
printf("Sorry, the word was under cup %d. BETTER LUCK NEXT TIME!\n",
coinPosition);
do {
printf("Do you want to play again? (y/n): "); // Prompt for replay
if (playAgain != 'y' && playAgain != 'Y' && playAgain != 'n' && playAgain != 'N') {
} while (playAgain != 'y' && playAgain != 'Y' && playAgain != 'n' && playAgain != 'N'); //
Repeat until valid input is entered
Page 9 of 15
} while (playAgain == 'y' || playAgain == 'Y'); // Continue playing if the user enters 'y' or 'Y'
CODE ORGANIZATION
Header Files
Libraries
Page 10 of
15
Test Plan:
I tested the game using my 2 nd year classmates in IT Class. They enter different letter,
special characters, and different numbers. Before, the program is not functioning and not
working and the system is just repeating every time they entered an invalid input, with that, I
knew that my code is not enough and need to put more condition to execute the game program I
imagined, like if the user's input wrong choice the program must state “invalid input” or “wrong
choice” and ask again.
At first, every time the user input “n” or “y”, the program will just ends and with that, I came up
with the solution to put another do-while loop because the function of this loop is a control flow
statement that executes a block of code at least once, and then repeats it or exits depending on
a condition, the code block executed first, then the condition is checked. The loop will repeat as
long as the condition is true.
Page 11 of
15
Sample Input/Output:
Page 12 of
15
The game “Find the word-Guessing Game” the word The game works as expected,
providing a simple and fun experience where players try to guess which cup hides the word. The
randomization feature ensures the game is unpredictable each time, and the input validation
prevents errors by checking if the player enters a number between 1 and 3. The score and
rounds are also tracked correctly, which keeps the game engaging by giving immediate
feedback.
However, there are a few areas that could be improved. The gameplay is limited because
there are only three cups, and the difficulty doesn’t change, so it can get repetitive. The game is
also text-based, which makes it less visually interesting compared to modern games. Adding
graphics or animations could make it more engaging. Additionally, the game doesn’t have a
reward system or challenges beyond the score, which might make it less exciting over time.
The input handling works well but could be more robust, as it currently only checks for
numbers between 1 and 3. Improving how the game handles different types of incorrect input
would make it more user-friendly. Also, the language used in the game may not be relatable to
everyone, which could limit its appeal to a wider audience.
In conclusion, the game is simple and functional but could be made more enjoyable and
engaging with added complexity, better visuals, and improved features. These changes would
make the game more fun and appealing to a larger group of people.
The program is an interactive guessing game where the user has to predict which "cup"
hides a word. It uses srand(time(0)) to randomize the position of the hidden word, ensuring
unpredictability in each round. The user is asked to guess a number between 1 and 3, and the
program provides feedback depending on whether the guess is correct or not. If the guess is
right, the program congratulates the player and increases their score; if it's wrong, it reveals the
correct answer and motivates the user to try again. The game also keeps track of the total
rounds played and the player's score, displaying them at the end of each round. The
motivational messages and clear instructions make the game fun and engaging for players. The
program shows good programming practices, especially with its input validation. It ensures that
Page 13 of
15
the user enters a number between 1 and 3 and handles invalid inputs, such as letters or
numbers outside the range, by clearing the input buffer and asking for a valid response. The
replay feature is also effective, allowing the player to continue or quit the game by entering 'y' or
'n'. The loops and structure of the program make it easy to follow and user-friendly. The game is
entirely text-based, which limits its appeal in an era where graphical interfaces dominate
gaming.
The game has several limitations that affect its depth and replayability. Firstly, it lacks variety, as
the gameplay revolves around guessing which "cup" hides the word, with no additional
challenges, levels, or modes to make it more engaging. The scoring system is static and does
not provide meaningful incentives or feedback beyond displaying the score and rounds played.
Additionally, while the instructions mention achieving 6 points out of 10 games, this goal is not
explicitly implemented as a win/loss condition, leaving the game without a clear endpoint or
purpose. Another limitation is the text-based interface, which makes the game less visually
appealing and engaging compared to modern graphical games. Input handling, while functional,
could be improved to better handle edge cases like excessively large inputs or repeated invalid
entries. The cultural and language-specific messages in the game, such as "PAPASA AKO SA
PROGRAMMING," may also limit its relatability to a broader audience. Furthermore, the
program is not easily scalable; the logic is hardcoded for three cups, making it difficult to expand
or modify the game for more complex setups. Overall, the game combines randomness, clear
feedback, and input handling to create an enjoyable and well-implemented experience.
FUTURE ENHANCEMENTS
To improve the game in the future, several enhancements can be added to make it more fun
and engaging. One idea is to introduce multiple difficulty levels by increasing the number of
cups or adding a time limit for guesses. This would make the game more challenging and
interesting. Another improvement is creating a graphical interface to replace the text-based
design, making the game more visually appealing with animations and sound effects. Adding
multiplayer functionality to gain more player at a time.
Additional features like a proper win or loss condition, such as reaching a specific score to
win, could give players clear goals. Adding new game modes, like bonus rounds or memory
challenges, would also add variety and excitement. Improving input handling to ensure
Page 14 of
15
smoother gameplay and using more relatable messages would make the game accessible to a
wider audience. Finally, making the code scalable and flexible would allow for easier updates
and expansions in the future.
CONCLUSION
The "Find the Word Guessing Game" demonstrates basic programming concepts like loops,
conditionals, and randomness in C. This project is a simple text-based guessing game where
players try to guess which cup hides the word, using randomization and input validation. It
tracks the player’s score and rounds while providing feedback and the option to play again. The
impact of the game is primarily educational, helping to practice basic programming concepts like
loops, random numbers, and input handling. However, the game is limited in terms of
replayability and user engagement due to its lack of variety and visual appeal. To make a bigger
impact, future improvements like adding difficulty levels, a graphical interface, and more
interactive features could make the game more fun and appealing to a larger audience.
Page 15 of
15