0% found this document useful (0 votes)
11 views

Programming

Uploaded by

Gretz CG-Araneta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Programming

Uploaded by

Gretz CG-Araneta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

CITY COLLEGE OF DEPARTMENT OF COMPUTING AND INFORMATICS

CALAMBA
Dalubhasaan ng Lungsod ng Calamba
FUNDAMENTALS OF PROGRAMMING

TITLE:

“FIND THE WORD – GUESSING GAME”

Valdez, Shelah L.

Bachelor of Science in Information and Technology

Prof. Joster Mirabeles

Page 1 of 15

Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna


(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF DEPARTMENT OF COMPUTING AND INFORMATICS
CALAMBA
Dalubhasaan ng Lungsod ng Calamba
FUNDAMENTALS OF PROGRAMMING

December 14, 2024

TABLE OF CONTENTS

I. TITLE PAGE ..................................................................................................... 1

II. TABLE OF CONTENTS ................................................................................... 2

III. INTRODUCTION .............................................................................................. 3-4

IV. SYSTEM/PROGRAM OBJECTIVES ..................................................................4

V. SYSTEM/PROGRAM FEATURES ..................................................................... 4

VI. REQUIREMENTS ............................................................................................... 5

VII. SYSTEM/PROGRAM DESIGN ............................................................................ 6

VIII. CODE IMPLEMENTATION .................................................................................. 7-10

IX. TESTING AND DEBUGGING ..............................................................................11-12

X. RESULTS AND ANALYSIS .................................................................................. 13

XI. CHALLENGES AND LIMITATIONS ....................................................................13-14

XII. FUTURE ENHANCEMENT ..................................................................................14-15

XIII. CONCLUSION ..................................................................................................... 15

Page 2 of 15

Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna


(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF DEPARTMENT OF COMPUTING AND INFORMATICS
CALAMBA
Dalubhasaan ng Lungsod ng Calamba
FUNDAMENTALS OF PROGRAMMING

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

Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna


(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF DEPARTMENT OF COMPUTING AND INFORMATICS
CALAMBA
Dalubhasaan ng Lungsod ng Calamba
FUNDAMENTALS OF PROGRAMMING

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

1. Random placement of a hidden word under one of three cups.


2. Input validation to ensure guesses are within the valid range.

Page 4 of 15

Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna


(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF DEPARTMENT OF COMPUTING AND INFORMATICS
CALAMBA
Dalubhasaan ng Lungsod ng Calamba
FUNDAMENTALS OF PROGRAMMING

3. Replay option with cumulative score tracking.


4. User-friendly prompts and feedback messages.

REQUIREMENTS

Hardware Requirements

- Processor: 1 GHz or higher (any modern CPU)


- RAM: 512 MB or higher of RAM
- Storage: 5 MB of free space

Software Requirements:

- Operating System: ( Windows, Linux, MacOs)


- Compiler: GCC or compatible C compiler

Page 5 of 15

Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna


(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF DEPARTMENT OF COMPUTING AND INFORMATICS
CALAMBA
Dalubhasaan ng Lungsod ng Calamba
FUNDAMENTALS OF PROGRAMMING

SYSTEM/PROGRAM DESIGN: FLOWCHART

START

Wrong (0 point)
Correct (1point) (1,2,3)
v

Play Again

Y/N?

THANK YOU

END

Page 6 of 15

Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna


(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF DEPARTMENT OF COMPUTING AND INFORMATICS
CALAMBA
Dalubhasaan ng Lungsod ng Calamba
FUNDAMENTALS OF PROGRAMMING

CODE IMPLEMENTATION

#include <stdio.h> : It is the standard input/output library

#include <stdlib.h> : It includes functions like rand() and srand()

#include <time.h> : It includes time() for random seed initialization

int main() {

int wordPosition, playerGuess, score = 0, rounds = 0; // Declare variables for the game's logic

char playAgain; // Variable to store the user's choice to replay

// Seed the random number generator with the current time

srand(time(0)); // Ensures randomness by using the current time as a seed

do {

// Randomly place the word under one of three cups (1, 2, or 3)

wordPosition = rand() % 3 + 1; // Generate a random number between 1 and 3

// Display the game's instructions to the user

printf("\nWelcome to the Find the Word Guessing Game!\n");

printf("A word is hidden under one of three cups (1, 2, or 3).\n");

printf("Can you guess which cup hides the word?\n");

Page 7 of 15

Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna


(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF DEPARTMENT OF COMPUTING AND INFORMATICS
CALAMBA
Dalubhasaan ng Lungsod ng Calamba
FUNDAMENTALS OF PROGRAMMING

printf("PAG NAKA 6 PTS KA OUT OF 10 GAMES, HANAPIN MOKO-_-\n");

do {

printf("\nEnter your guess (1, 2, or 3): "); // Prompt the user for a guess

if (scanf("%d", &playerGuess) != 1) { // Check if the input is a number

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

continue; // To restart the guessing loop

// To ensure if the guess is between 1 and 3

if (playerGuess < 1 || playerGuess > 3) {

printf("Invalid choice! You must enter a number between 1 and 3.\n");

} while (playerGuess < 1 || playerGuess > 3); // Repeat until a valid guess is entered

rounds++; // Increment the number of rounds played

// Check if the player's guess matches the word's position

if (playerGuess == coinPosition) {

// Congratulate the user if they guessed correctly

Page 8 of 15

Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna


(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF DEPARTMENT OF COMPUTING AND INFORMATICS
CALAMBA
Dalubhasaan ng Lungsod ng Calamba
FUNDAMENTALS OF PROGRAMMING

printf("CONGRATULATIONS! Nahanap mo ang word *PAPASA AKO SA


PROGRAMMING* under cup %d, for sure papasa kana!!!\n", coinPosition);

score++; // Increase the user's score

} else {

// Inform the user of the correct answer if they guessed wrong

printf("Sorry, the word was under cup %d. BETTER LUCK NEXT TIME!\n",
coinPosition);

// Display the user's current score and rounds played

printf("\nYour current score: %d/%d rounds\n", score, rounds);

// Ask if the the user wants to play again

do {

printf("Do you want to play again? (y/n): "); // Prompt for replay

scanf(" %c", &playAgain); // Read the user's input

// Validate the user's input

if (playAgain != 'y' && playAgain != 'Y' && playAgain != 'n' && playAgain != 'N') {

printf("Invalid input! Please enter 'y' or 'n'.\n");

} while (playAgain != 'y' && playAgain != 'Y' && playAgain != 'n' && playAgain != 'N'); //
Repeat until valid input is entered

Page 9 of 15

Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna


(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF DEPARTMENT OF COMPUTING AND INFORMATICS
CALAMBA
Dalubhasaan ng Lungsod ng Calamba
FUNDAMENTALS OF PROGRAMMING

} while (playAgain == 'y' || playAgain == 'Y'); // Continue playing if the user enters 'y' or 'Y'

// Display the final score and a farewell message

printf("\nFinal score: %d/%d rounds\n", score, rounds);

printf("Thank you for playing! Nice Game!\n");

return 0; // End of the program

CODE ORGANIZATION

Header Files

● #include <stdio.h> : It is the standard input/output library

● #include <stdlib.h> : It includes functions like rand() and srand()

● #include <time.h> : It includes time() for random seed initialization

Libraries

● Standard libraries like ( <stdio.h>, <stdlib.h>, and <time.h>) are used.

Page 10 of
15

Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna


(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF DEPARTMENT OF COMPUTING AND INFORMATICS
CALAMBA
Dalubhasaan ng Lungsod ng Calamba
FUNDAMENTALS OF PROGRAMMING

TESTING AND DEBUGGING

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

Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna


(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF DEPARTMENT OF COMPUTING AND INFORMATICS
CALAMBA
Dalubhasaan ng Lungsod ng Calamba
FUNDAMENTALS OF PROGRAMMING

Sample Input/Output:

RESULTS AND ANALYSIS

Page 12 of
15

Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna


(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF DEPARTMENT OF COMPUTING AND INFORMATICS
CALAMBA
Dalubhasaan ng Lungsod ng Calamba
FUNDAMENTALS OF PROGRAMMING

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.

CHALLENGE AND LIMITATIONS

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

Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna


(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF DEPARTMENT OF COMPUTING AND INFORMATICS
CALAMBA
Dalubhasaan ng Lungsod ng Calamba
FUNDAMENTALS OF PROGRAMMING

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

Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna


(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph
CITY COLLEGE OF DEPARTMENT OF COMPUTING AND INFORMATICS
CALAMBA
Dalubhasaan ng Lungsod ng Calamba
FUNDAMENTALS OF PROGRAMMING

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

Old Municipal Site, Brgy. VII, Poblacion, Calamba City, Laguna


(049) 559-8900 to 8907 / (02) 8-5395-170 to 171
ccc.edu.ph

You might also like