online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> #include <random> #include <string> using namespace std; random_device rd; bool running = true; int number_1; int number_2; //these two are the numbers that are randomized. int instruction; //the student's input int score = 0; //a score keeping thing to make it seem fun, I guess int streak = 0; //and a streak to see how long a student can get things right int main() { while (running = true) { //this while statement lets it repeat number_1 = rd() % 11; number_2 = rd() % 11; cout<<"Please add "<<number_1<<" and "<<number_2<<"\n"; cout<<"Type your answer and press enter when you're ready.\n"; cin>>instruction; if (instruction == number_1 + number_2) { cout<<"Correct! Nicely done!\nPress enter to continue."; score = score + 10; streak = streak + 1; getchar(); getchar(); } else { cout<<"Sorry, that's incorrect... Press enter to see the correct answer."; getchar(); getchar(); cout<<number_1<<" plus "<<number_2<<" is "<<number_1 + number_2; score = score - 5; streak = 0; getchar(); } cout<<"Your score: "<<score<<"\n"; if (streak >= 3) { cout<<"You're on a roll! You have a streak of "<<streak<<" correct answers in a row!\n"; } } }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue