Mini Project Final
Mini Project Final
UNDER
BENGALURU NORTH UNIVERSITY, KARNATAKA
SUBMITTED BY:
AARON P S ( U19CU24SOO31 )
CERTIFICATE
I would like to sincerely thank our Dean, Professor P.M. Shyjan, Dr.
Rajendra Prasad, Principal, KRUPANIDHI DEGREE COLLEGE for providing
the facilities.
I sincerely thank Prof. Kavitha H S, Head of the Department, for her
assistance and collaboration during the duration of the mini project.
I express deep gratitude to my guide Mrs.VEENA GRACE CARMEL for
her valuable advice, timely suggestions and assistance in the realization of this
mini project.
My heartfelt thanks to all the staff members and non-teaching staff of the
Computer Science department for providing the necessary facilities and support.
Without the support of any one of them, this mini project would not have been a
reality.
I am also grateful to my friends for their valuable suggestions for the success
of the project.
I also thank my parents for their support in all our activities, without which I
would not have been able to carry out the project.
Place: Bengaluru Name: AARON P S
Date: ATHUL MOHAN K P
ABSTRACT
This project culminates in the creation of a dynamic and interactive mathematical calculation
game, meticulously developed using the C programming language. The primary objective of
this endeavor is to provide users with an engaging and effective platform to significantly
enhance their arithmetic proficiency and mental agility. The core functionality revolves
around the procedural generation of randomized mathematical expressions, encompassing the
fundamental operations of addition, subtraction, multiplication, and division, along with the
strategic inclusion of parentheses to increase complexity. These expressions are presented to
the user as time-sensitive challenges, demanding accurate and timely responses within a
predetermined time frame. The game's architecture emphasizes real-time interaction,
necessitating swift mental calculations and precise input, fostering a dynamic learning
environment. A robust scoring mechanism is implemented to meticulously track and evaluate
user performance, providing immediate and comprehensive feedback that serves to motivate
and guide the user's learning process. This system incorporates bonus points for rapid and
accurate responses, while also applying penalties for incorrect answers or exceeding time
limits, thereby incentivizing both speed and accuracy. The design incorporates a dynamic
difficulty adjustment, ensuring that the game adapts to the user's skill level, thereby providing
an optimal learning experience and preventing frustration. The game also includes robust
error handling, to ensure program stability and prevent crashes, and comprehensive input
validation, to guarantee that user input adheres to expected formats. The time limit associated
with each problem adds an element of urgency, pushing users to improve their calculation
speed and accuracy, thereby sharpening their mental reflexes. Furthermore, the game will
save, and load the high scores of the user, adding a competitive element. The project aims to
provide an educational and entertaining experience, seamlessly blending learning with the
thrill of competitive gameplay. The game is designed to run in a standard terminal
environment, ensuring broad compatibility and ease of portability across various operating
systems. The game's modular design allows for future expansion, including the addition of
more complex mathematical concepts and gameplay modes.
CONTENTS
1 INTRODUCTION 1-2
2 HISTORY 3-4
3 CODING 5-8
5 OUTPUT SCREENSHOT 12
6 CONCLUSION 13-14
7 BIBLIOGRAPHY 15-16
TMS
Introduction
Calculation games serve as invaluable tools for enhancing mathematical proficiency and
bolstering cognitive skills, offering a dynamic and engaging approach to learning and
reinforcing arithmetic concepts. This project is dedicated to the creation of an interactive
math challenge game using the C programming language, providing users with a stimulating
and interactive platform to practice and refine their arithmetic abilities. The game will
dynamically generate random mathematical expressions, encompassing a range of operations
and complexities, allowing users to rigorously test and enhance their calculation speed,
accuracy, and mental agility.
The project will delve into the fundamental concepts of game development in C, exploring
and implementing key functionalities such as robust random number generation, efficient
input/output operations, and the precise execution of basic arithmetic calculations. We will
leverage the rand() function, seeded with time (NULL), to ensure a diverse and unpredictable
set of mathematical challenges. Furthermore, we will implement input validation to ensure
that user input is in the correct format, and handle errors gracefully. The project will
demonstrate how C can be effectively utilized to create interactive and educational
applications, showcasing its versatility and power in developing engaging software.
Beyond the basic arithmetic operations, this project will also explore the potential to
incorporate more advanced features, such as varying difficulty levels, timed challenges, and a
scoring system to track user progress. The dynamic difficulty adjustment will tailor the
game's complexity to the user's performance, ensuring a challenging yet rewarding
experience. The inclusion of timed challenges will add an element of urgency, encouraging
users to improve their calculation speed and accuracy. The scoring system will provide
immediate feedback, motivating users to strive for higher scores and track their progress over
time. The project will also include file I/O, so that high scores can be saved and loaded.
1|Page
TMS
The aim is to develop a game that is not only educational but also entertaining, providing a
stimulating and enjoyable way for users to improve their mathematical skills. The game will
be designed to run in a standard terminal environment, ensuring broad compatibility and ease
of use. The modular design of the game will allow for future expansion, including the
addition of more complex mathematical concepts and gameplay modes, further enhancing its
educational value and entertainment potential.
2|Page
TMS
The history of calculation games is a rich tapestry, interwoven with the evolution of
educational tools and the advancement of computational technology. From the earliest forms
of arithmetic practice to the sophisticated digital applications of today, calculation games
have consistently served as a vital means of enhancing mathematical proficiency and
cognitive development.
The origins of calculation games can be traced back to ancient times, with tools like the
abacus representing some of the earliest forms of computational aids. Arithmetic puzzles and
riddles, often passed down through generations, also played a significant role in developing
mathematical reasoning and problem-solving skills. These early tools and puzzles laid the
foundation for the structured learning of mathematics, emphasizing the importance of
practice and mental agility.
3|Page
TMS
The evolution of calculation games reflects the ongoing quest to make learning more
effective and enjoyable. As technology continues to advance, we can expect to see even more
innovative and engaging calculation games that will further enhance mathematical
proficiency and cognitive development.
4|Page
TMS
4.Code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ctype.h>
// Word bank
char words[NUM_WORDS][20] = {
"programming", "computer", "algorithm", "database", "network",
"software", "hardware", "interface", "function", "variable",
"structure", "pointer", "memory", "process", "thread",
"compile", "debug", "syntax", "library", "execute"
};
5|Page
TMS
char *getRandomWord() {
return words[rand() % NUM_WORDS];
}
int main() {
srand(time(NULL)); // Seed random generator
char input[20]; // User input
char *targetWord;
int correctWords = 0, correctChars = 0;
time_t startTime, endTime;
float timeTaken;
startTime = time(NULL);
6|Page
TMS
if (strcmp(input, targetWord) == 0) {
printf(GREEN " ✅ Correct!\n" RESET);
correctWords++;
correctChars += strlen(targetWord);
} else {
printf(RED " ❌ Wrong! The correct word was: %s\n" RESET, targetWord);
}
}
endTime = time(NULL);
timeTaken = difftime(endTime, startTime);
float wpm = calculateWPM(correctChars, timeTaken);
7|Page
TMS
// Encouraging message
if (correctWords == TOTAL_ROUNDS) {
printf(GREEN " 🎉 Perfect score! You're a typing master! 🎉\n" RESET);
} else if (correctWords >= TOTAL_ROUNDS / 2) {
printf(YELLOW "👍 Great job! Keep practicing to get even faster!\n" RESET);
} else {
printf(RED "💡 Don't worry! Practice makes perfect!\n" RESET);
}
return 0;
}
8|Page
TMS
The core functionality of the C-based math calculation game revolves around the generation
of random arithmetic problems and the evaluation of user responses. The
generateRandomNumber function plays a pivotal role in creating the dynamic nature of the
game, producing pseudo-random integers within a user-defined range. This range can be
adjusted to control the difficulty of the generated problems. The performCalculation function
then takes these random integers and applies basic arithmetic operations (addition,
subtraction, multiplication, and division) based on a randomly selected operator.
● Scoring Mechanism:
o The game implements a scoring system to track user performance, providing immediate
feedback on the correctness of each answer. This scoring system serves as a motivational
tool, encouraging users to improve their arithmetic skills and strive for higher scores.
o The scoring system provides data on the users preformance, which can be used to adjust the
difficulty.
● Error Handling:
9|Page
TMS
● User Profiles:
o Implementing user profiles, and saving user data, would allow for personalization of the
game, and would also allow the user to track their own progress.
● Graphical User Interface(GUI):
o Implementing a GUI would greatly improve the user experience.
10 | P a g e
TMS
o Adding parenthesis, and more operands to the generated expressions, would greatly
increase the difficulty of the game.
6.Output Screenshots
11 | P a g e
TMS
7. Conclusion
This project has successfully implemented a functional and engaging math calculation game
using the C programming language. The game provides users with a valuable and interactive
platform to practice fundamental arithmetic skills, ultimately enhancing their calculation
speed, accuracy, and mental agility. By generating random mathematical expressions and
requiring timely responses, the game fosters a dynamic learning environment that encourages
users to think critically and react swiftly.
The project effectively demonstrates the application of C programming in the realm of game
development, highlighting the language's versatility and power in creating interactive and
educational applications. The successful implementation of random number generation, using
srand(time(NULL)) and rand(), ensures a diverse and unpredictable set of mathematical
challenges, maintaining user engagement and promoting continuous learning. Robust input
handling, using scanf, ensures that the program can gracefully handle user input, and that the
program is stable. The basic error handling implemented prevents common errors, such as
12 | P a g e
TMS
division by zero.
The development process has provided valuable insights into the design and implementation
of interactive applications in C, emphasizing the importance of clear code structure, efficient
algorithm design, and thorough testing. The project has also reinforced the significance of
user-centered design, highlighting the need to create intuitive and engaging interfaces that
facilitate effective learning.
Future Enhancements and Potential Developments:
● Timer Implementation:
o Integrating a timer mechanism to introduce time constraints for each question would
significantly enhance the game's challenge and promote faster calculation speeds. This
feature would add an element of urgency, encouraging users to improve their mental agility
and quick-thinking abilities.
● Dynamic Difficulty Levels:
o Implementing dynamic difficulty levels by adjusting the range of numbers and the
complexity of operations would cater to users of varying skill levels. This adaptive feature
would ensure a personalized learning experience, providing appropriate challenges and
preventing frustration.
● Graphical User Interface (GUI):
o Developing a graphical user interface (GUI) would significantly enhance the game's visual
appeal and user experience. A GUI would allow for more interactive elements, animations,
and visual feedback, making the game more engaging and enjoyable.
● Expanded Operator Set:
o Expanding the set of supported arithmetic operations to include modulus, exponents, roots,
and other mathematical functions would increase the complexity and educational value of
the game. This would provide users with a broader range of mathematical challenges,
fostering a deeper understanding of mathematical concepts.
● High Score Tracking and Persistence:
o Implementing a high score tracking system and saving high scores to a file would add a
competitive element to the game, motivating users to strive for higher scores and track their
progress over time.
13 | P a g e
TMS
14 | P a g e
TMS
8. Bibliography
This project drew upon a variety of resources, encompassing foundational C programming
texts, online tutorials, and the official C Standard Library documentation. The following
bibliography provides a more detailed overview of the materials consulted:
● "C Programming: A Modern Approach" by K.N. King:
o This comprehensive textbook served as a primary resource for understanding the intricacies
of the C programming language. It provided in-depth explanations of core concepts,
including data types, operators, control flow, functions, and memory management. Its clear
and concise writing style, coupled with numerous examples, facilitated a thorough
understanding of C programming principles. This book was especially useful for
understanding memory management, which is important for optimization.
● "Programming in C" by Stephen G. Kochan:
o This widely acclaimed book provided a practical and accessible introduction to C
programming. Its step-by-step approach and emphasis on real-world examples made it an
invaluable resource for learning the fundamentals of C. It was very useful for learning
about standard library functions.
● Online Resources and Tutorials on C Programming and Game Development:
15 | P a g e
TMS
o Numerous online resources and tutorials were consulted to supplement the textbook
learning. Websites such as GeeksforGeeks, TutorialsPoint, and Stack Overflow provided
valuable insights into specific C programming concepts and game development techniques.
These resources offered practical examples, code snippets, and solutions to common
programming challenges.
o Websites such as learn-c.org were also utilised.
16 | P a g e