int guess, num = random(1, 25);
cout << "\nWelcome to Number Guessing Game\n\n";
cout << "Guess a number between 1 and 25: ";
cin >> guess;
if (guess == num)
cout << "\n\nYou have guessed correctly! The number was: " << num;
cout << "\n\nSorry. That guess was incorrect. The number was: " << num;
//Protection loop - begin
cout << "\nDo you want to play again?(y/n) ";
cin >> response;
} while (response != 'y' && response != 'n');
//Protection loop - end
} while (response == 'y');
The "rand () % (range)" portion will generate a pseudo-random number, then get the remainder of said number divided by the range. This effectively gets a number within the range you want, but it is between zero and said range, so you need to add low to ensure that the number will always be between low and high.
This is being called outside of the loop, so even if it is properly generated at the start of the program, it will be the same number every time the user wants to guess. It's okay to declare the variables here, but call num = random(1, 25);
inside of your loop.