0

I'm having problems with my do/while loop. It does not take the condition and simply continues the loop indefinitely. I have:

do
{
   printf("Choose the base of the number to convert:\n\n");
   printf("2    5    8    10    16\n\n");
   printf("Enter option:");
   scanf("%d", &baseFrom);
   system("cls");
   if(baseFrom != 2 || baseFrom !=5 || baseFrom != 8 || baseFrom != 10 || baseFrom != 16)
      printf("Incorrect choice, please try again.\n\n");
} while( baseFrom != 2 || baseFrom !=5 || baseFrom != 8 || baseFrom != 10 || baseFrom != 16);

I even tried it with cin cout and still gives the same outcome: the loop just continues

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Salem
0

> baseFrom != 2 || baseFrom !=5
So you type in 2
The first one becomes false (good)
The second one (and all the others) remain true (not so good)

You probably want && , not ||

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.