int targetNumber = rand() % 20 + 1; // generates a random number from 1 to 20. try without + 1 to see what happens ...