Hey there! I'm wonder of how to store a score I am doing a question game and needs to store coins for every question the user enters the correct answer. I want to do something like when you have completed the first question then the program will give you +3 in coins then you have completed next question then I want the program to add 3 more so it says you have a value of coins 6. But I do not know exactly how to do this the code I begun to write was this:
This code works for 1 question but I want it to work like add 3 for every question the user guesses correct. Like if user enters the correct answer 3 times then he/she has a value of coins 9.Code:#include <iostream> using namespace std; int main() { int answer; int coins = 3; //Have no questions yet if you wonder cout << "Question1"; cin >> answer; if (answer == 1) { cout << "Correct!" << coins; } else if (answer != 1) { cout << "Wrong!"; } return 0; }