I am trying to create a program that produces random addition problem. When the user gets the answer correct how do I make it to where it displays 4 different types of responses when you get the answer right? Like if you get it right, it randomly generates great job, well done, and so on. How do I do that?
This is my program so far but it only generates one response for now:
#include "stdafx.h"
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int userGuess, answer, num1, num2;
cout << "Welcome to the addition game!" << endl;
cout << "Calculate the problems below, when finished type -1 to view results.\n\n";
PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/ http://www.cplusplus.com/articles/z13hAqkS/
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.
Give this a try. I have not tested this yet, but I believe the concept is right:
In the first if statement it should have been (userGuess == answer), but what you have works fine. Since "answer" was unused I gave it a different use. I will leave it to you to finish out.
Keep the switch/case code somewhere for future use.