I'm trying to get a number of rooms and it can't be less than 1. I have this do loop with and if statement but when i enter invalid input it just outputs invalid output and goes onto my next function.
Code:int num_of_rooms() { int num_rm, valid = 1; do { cout << "Enter the number of rooms: "; cin >> num_rm; if (num_rm < 1) { valid = 0; cout << "Invalid input\n"; } }while(valid = 0); return num_rm; }