This is my program, doing conversions between F and C
The only problem with this is that the while loop will loop infinitely even when the user input 1 or 2. I could change while (ui!= 1 || ui!= 2) to if (ui!= 1 || ui!= 2) but doing so will only allows user to have 2 chances to enter the correct numbers (1 or 2). I want the program to keep asking for the right user input til they get it right. I think I can do it with switch statements but I'm not there yet so I'd love to stick with if and while for this. Please any advice?
while (ui!= 1 || ui!= 2){
cout << "Please enter 1 or 2 only !" << endl;
cin >> ui;
{ while (ui!= 1 || ui!= 2){
cout << "Please enter 1 or 2 only !" << endl;
}
The problem is that ui!= 1 || ui!= 2 can never be false. If ui!= 1 is false then ui!= 2 must be true and vice versa so the whole expression will always be true and the loop will never end.