lundi 10 octobre 2022

Loop is not repeating c++ [closed]

Hi everyone I am new to c++. I am trying to validate that a user-entered number should be greater than or equal to 9 as well as odd. If the value entered is invalid I am supposed to let the user know and ask for another value until its valid. I understand that my approach to this should be a while loop. But for some reason, my loop only iterates once. I would appreciate any and all help on this.

int main()
{

    int size;

    cout<<"Enter the size: ";
    cin>>size;
    
    while(size < 9 && size % 2 == 0);
    {
        cout<<"Invalid letter: Enter the letter again: ";
        cin>>size;
    }
    return 0;

Aucun commentaire:

Enregistrer un commentaire