What I think main does

It does the following things:

  • It sets the integer variable called “difficulty” to 2 and set the variable "maxDifficulty to 10,
  • Then it creates a while loop that runs while the variable difficulty is less or equal than maxDifficulty (10)
  • It calls the function PlayGameAtDifficulty and uses the value of the variable difficulty as a parameter.
  • when it finishes running the function, then clears failbit and buffer, which I suppose is some kind of garbage cleaning method.
  • then increments the value of difficulty by 1, which will make the while loop to iterate, until it gets to 10
  • after difficulty is higher than 10, then it prints a message to the user congratulating them for completing the game.
  • then it exits the session without an error.

Privacy & Terms