Who Will Be The Millionaire
(Using File Directory)
Nafisa Binta Tofayel (180205)
Jawadul Islam (180213)
Musfiq Rahman (180214)
Jannatul Ferdous (180215)
Mukit Hasan Pranto (180224)
Computer Science and Engineering Discipline,
28 October 2018.
C is an inevitable part of coding. Most of us who wants to learn programming as a beginner, starts by learning C. Mini projects like creating games or applications is always fun and challenging for a beginner programmer who completed learning the core parts of C language. The game “Who Will Be The Millionaire” is inspired by the famous reality show goes with the same name. The source code is not that long, over 400 lines. It is compiled in Code::Blocks IDE with GCC compiler. Various sound effect has been added to this project so in compiler linker settings “winmm” has been added. To help understand the code many comments will be given in the source code.
N.B: This project is created with file directory so other .txt file is as important as the source file.
Click on the link below to directly download the source file along with other important files used in this project.
Click here to download all the mandatory files needed for this project ->
About This Project
The project on “Who Will Be The Millionaire” is an console application which has no graphics interface. Although various sound effects are used. The unique thing about this game is, it is created mainly by file directory. Total number of 15 questions will be presented in the game and all 15 of them will be randomly selected from 15 files which contains 10 questions each. A total number of 32 .txt files are created. 15 files for questions and 15 files for answer and lastly 2 files for adding and showing records. There are also 3 .wav files created for Intro, right answer and wrong answer background music. The prize pool ladder for 15 questions is as same as the original.
First of all, to add audio effect “winmm” library need to be added in the compiler linker setting.
The game opens in the main menu which has 3 options.
By pressing ‘I’, the introduction window pops up, in which the prize money ladder is explained.
By pressing ‘R’, the previous records for the game shows up.
By pressing ‘S’, The game of knowledge begins. For every right answer, player will get the rightful amount of prize money and climb up the ladder.
But for a wrong answer, the game will be terminated and player will return to the main menu.
The functions used in the source code are simple and easy to understand. They are described in the source code with comments.
The following library functions are used:
- <stdio.h> – for standard input output
- <conio.h> – for console input output
- <ctype.h> – for case sensitivity
- <time.h> – for generating a random number
- <windows.h> – for declaration of all the function especially <MMSystem.h>
- <MMSystem.h> – multimedia function for adding multimedia files.
The following user defined functions are used:
- void open_sector(char question, char answer) : This is the most important function. It contains two other functions named as ‘void questions() and ‘void answer_match()’. It opens both the question and answer files in reading mode. After that it calls both the functions.
- void question(): First a random number is generated by using srand(time(0)), rand() and <time.h>. Then it prints a random question with options.
- void answer_match(): First an input is taken from the user then it matches with the correct answer. If it doesn’t match the answer then the game will take user to the main menu.
- void add_record(): After every game ends. The name of the player and the prize money is printed in a separated file.
- void show_record(): It shows the previous records in the console by printing the values from the file.
Thank you very much.