C++ error: expected ; before


int main() {

int guess;

int tries = 0;

std::cout << “I have a number 1-10.\n”;
std::cout << "Please guess it: ";
std::cin >> guess;

// Write a while loop here:

while (guess != 8 && tries < 50) {
std::cout << "Wrong guess try again: ";
std::cin >> guess;

tries ++ 1;


if (guess == 8) {

std::cout << "You got it!\n";



Hi all this code os for a number guesser that Is a task in one of the lessons in the c++ Codecademy course. It gives me a pass but when I try and compile the program in the terminal it gives me the error of guess.cpp:19:14: error: expected ‘;’ before numeric constant
tries ++ 1;
This has also happened before on other tasks and even when I copy the code directly from the hint box it gives an error similar to this, always including an expected ; before something. Thanks

Hello @blog6491351288, welcome to the forums! When you use tries ++ it means add one to the tries variable. So you don’t put a number after it:

int x = 0;
x++;//x is now 2
x++1;//throws an error

If you want to add any other number to a variable, you can use +=:

int x = 0;
x += 3;//x is now 3