Hi can anybody provide me with the code for c++ programme for the famous game who wants to be a millionaire.

Thanks

jonsca commented: Check with Regis Philbin... -1

Dani AI

Generated

A compact, practical blueprint for a console "Who Wants to Be a Millionaire" in modern C++ (C++11+), building on ideas already suggested by (external question storage) and (menu + separate classes). Start by modelling the data and game responsibilities, keep I/O separate from logic, and use the standard library for randomness and containers so behavior is predictable and testable.

A minimal data model:

struct Question {
    int level;                   // difficulty or money-tier index
    std::string text;
    std::array<std::string,4> options; // A,B,C,D
    char correct;                // 'A'..'D'
};

Store questions in a simple delimiter format (CSV or pipe-separated) with one line per question:

level|question|A|B|C|D|correct
1|Which planet is known as the Red Planet?|Mercury|Venus|Mars|Jupiter|C

Use std::getline and a small parser to load rows, validate fields, and group questions by level so the game can pick an appropriate difficulty for each round.

For selection and lifelines, prefer <random> over rand(); seed std::mt19937 from std::random_device and shuffle candidate lists with std::shuffle:

std::random_device rd;
std::mt19937 gen(rd());
std::shuffle(questions.begin(), questions.end(), gen);

Implement lifelines as small strategies: 50:50 removes two wrong options chosen at random; Phone-A-Friend and Ask-The-Audience can simulate weighted guesses (higher probability for easier levels). Keep lifeline code deterministic under a test seed so behavior can be unit-tested.

Troubleshooting tips: handle file-not-found and malformed lines robustly; trim whitespace and do case-insensitive answer checks; ensure at least one question per level before starting; test with a fixed RNG seed to reproduce bugs; separate presentation (console I/O) from game rules so later upgrades (GUI, networked play, persistent high scores) are straightforward. A simple, well-tested structure like this keeps the project manageable for a newbie and provides clear extension points.

Recommended Answers

All 7 Replies

I suppose it's possible that someone could.

Not sure why they would want to really, but yeah, it's possible that they could.

well,
m a newbie just want some help, if u can get me started and tell me the way out i would be really very happy. I mean where shud i start from !! i hope u can understand.

Regds

Start with this:

#include <iostream>
#include <fstream>

using std::cin;
using std::cout;
using std::iostream;
using stdLLifstream;

int main()
{

   // your program goes here

}

Next you will have to create a list of questions and their four possible answers, save them in a text file or just hard code them in your program.

Select one of the questions at random, display the question and four possible answers. Then ask the user to enter a,b, c or d (one of the 4 possible answers). Repeat as often as necessary so that the user can win a million dollars.

I think you mean:

#include <iostream>
#include <fstream>
 
using std::cin;
using std::cout;
using std::iostream;
using std::ifstream;
 
int main()
{
 
   // your program goes here
 
}

I think you mean:

#include <iostream>
#include <fstream>
 
using std::cin;
using std::cout;
using std::iostream;
using std::ifstream;
 
int main()
{
 
   // your program goes here
 
}

Huh??? Isn't that the same thing I posted??? Both are incorrect. std::iostream should have been std::ofstream;

Thanks Man, I will get back if i require more help in this regards.

Make a menu first! Asking the user about various choices. eg to read a Qestion or to write or to eg delete an entry and then proceed with the development of seperate classes that corresponds to each menu item. Finally display the user choices on the console along with the points gathered.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.