DSA Report
DSA Report
Project Report
by
(2024-25)
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
(Under Section 3 of UGC Act, 1956)
BONAFIDE CERTIFICATE
Certified that the project report for the course 21CSC201j Data Structures and
Algorithm entitled in “Quiz Game in C” is the bonafide work Pranjal Piyush
RA2311003030109, Daksh Gupta RA2311003030112, Shraddha
RA2311003030119, Shreya Mehndiratta RA2311003030086 who carried out the
work under my supervision.
SIGNATURE SIGNATURE
1. Introduction 1
2. Requirements 1
3. Implementation 2
4. Code 4
5. Result 6
6. Conclusion 8
ACKNOWLEDGEMENT
I would like to express my sincere gratitude to all those who have supported and guided
me throughout the development of this project.
Firstly, I extend my heartfelt thanks to Dr. Dinesh Kumar, our Faculty Coordinator, for
her invaluable guidance, continuous encouragement, and timely feedback throughout
the project. Her mentorship has been crucial in shaping my understanding and pushing
me toward excellence.
I would also like to acknowledge the tremendous support and collaboration of my group
members. Their dedication, teamwork, and efforts played a significant role in the
successful completion of this project, and I am grateful for their cooperation at every
stage.
A special thanks to Dr. R. P. Mahapatra, Dean E&T (Engineering and Technologies), for
providing us with the necessary resources and a conducive environment for learning and
development. His leadership and vision have been instrumental in fostering innovation
and creativity in our academic journey.
This project would not have been possible without the collective efforts and guidance of
these esteemed individuals, and I extend my sincere appreciation to each one of them.
INTRODUCTION
The Quiz Game is a console-based program written in C, aimed at providing an
interactive way for players to challenge their knowledge. The game features a simple
interface where users can navigate between different options such as starting the game,
viewing the highest score, resetting the score, or quitting the game.
● Warmup Round: Players must answer at least three out of five questions
correctly to proceed.
● Challenge Round: Players answer 10 questions, each worth 100,000 points.
● Score Tracking: The game records and displays the highest score in the system,
adding a competitive element to gameplay.
● File Handling: The program uses file operations to store and retrieve the highest
score.
The primary goal is to reinforce core C programming concepts and show how they can
be used to build interactive console applications.
REQUIREMENTS
C Compiler: A C compiler such as:
Hardware Requirements:
● Main Function: The entry point of the program is the main function, where the game
starts. It initialises the necessary variables, displays the main menu, and controls the
game flow based on user input.
● Game Loop: The main loop continues running until the player decides to quit. It
offers options to start the game, view the highest score, reset the score, or exit the
program.
● Menu Options: When the game starts, the main menu is displayed using printf
statements. The user can choose one of the following options:
○ S: Start the game.
○ V: View the highest score.
○ R: Reset the score.
○ H: Help (instructions).
○ Q: Quit the game.
● User Input: The program captures the user's input using the getch() function,
which allows for immediate character reading without needing to press Enter.
Warmup Round
● Purpose: The warmup round serves as a qualification stage. Players must answer at
least three out of five questions correctly to advance to the challenge round.
● Question Display: Questions are displayed using printf, and the player's answers
are collected with getch(). The user's response is checked against the correct
answer, and the count of correct answers is updated accordingly.
● Qualification Check: After answering the questions, the program checks if the
player has answered at least three correctly. If not, the game prompts them to try
again.
Challenge Round
● Main Gameplay: Upon qualifying from the warmup round, players enter the
challenge round, where they answer a series of ten questions.
● Question Loop: A loop iterates through the questions, displaying them and checking
the user's answers similarly to the warmup round. Each correct answer adds points
to the player's score.
● Scoring System: Each question in the challenge round is worth a specified number
of points. The total score is calculated based on the number of correct answers.
Score Management
● Displaying the Highest Score: The program uses file handling to read the highest
score from a file (score.txt). If the file contains a score, it is displayed to the user.
● Updating the Score: If the player's final score exceeds the previously recorded
highest score, the program updates the file with the new score, along with the
player's name.
● Resetting the Score: The option to reset the highest score allows users to clear the
stored score, facilitating a fresh start for new players or returning players who want to
compete again.
File Handling
● Opening and Reading Files: The program opens the score.txt file for reading
the current highest score using the fopen() function. The fscanf() function reads
the contents into appropriate variables.
● Writing to Files: When updating the high score, the program opens the same file in
write mode ("w"), writing the new score and player name using fprintf().
● Closing Files: After file operations are completed, the program closes the file using
fclose() to ensure data integrity and prevent file corruption.
End of Game
● Program Termination: The game can be terminated by selecting the quit option from
the main menu. Upon quitting, the program exits gracefully, ensuring all resources
are released properly.
CODE
Main Menu:
Displays options for starting the game, viewing the highest score, resetting the score, or
quitting the game.
This section verifies if the user qualifies for the challenge round.
This snippet updates the score if the player exceeds the previous high score.
RESULTS
Future Enhancements
● Question Variety: To improve the game, more diverse questions can be added, and
categories can be introduced for a richer experience.
● User Interface: The console UI could be improved with better formatting and
perhaps a graphical interface for advanced implementations.
● Multiplayer Option: A multiplayer mode could be introduced, allowing players to
compete against each other in real-time.
Output
Main Menu:
This project highlights how these fundamental principles can be used to create interactive,
real-world applications. Future improvements could include adding more questions,
improving the user interface, and creating more advanced gameplay mechanics.