Can someone help me fix my points/score system in c++?
Emel1235JR (0)

code:

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
int score = 0;
int number;

cout << "This is a math game." << endl ;
cout << "You will get some tasks, every task is one point." << endl ;
cout << "But if you fail one you lose." << endl ;
cout << " " << endl ;

cout << "0 + 5 = " ;
cin >> number ;

if(number == 5){
cout << "Next" << endl ;
 score = score + number;

score++;
}else{
cout << "Fail" << endl ;
cout << "Your score is: " << score << endl ;
return 0;
}

cout << "5 + 13 = " ;

cin >> number ;

if(number == 18){
cout << "Next" << endl ;
 score = score + number;

score++;
}else{
cout << "Fail" << endl ;
cout << "Your score is: " << score << endl ;
return 0;
}

cout << "18 - 6 = " ;
cin >> number ;

if(number == 12){
cout << "Next" << endl ;
 score = score + number;

score++;
}else{
cout << "Fail" << endl ;
cout << "Your score is: " << score << endl ;
return 0;
}

}

You are viewing a single comment. View All
Answered by mat1 (2489) [earned 5 cycles]
View Answer
heyitsmarcus (287)

Can you please give some more details on what your problem is? Your C++ code runs fine. Although, you should put it into a repl beforehand, and then post the repl link instead of raw pasting the code.

You can look at the Markdown link below any comment to the right. Put three backticks (the default key for the ~ key) to start the code block, go to a new line, paste your code in, and then go to a new line, and put three more backticks.