When input is not a or b or c it should get input again. please help me solve it | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

When input is not a or b or c it should get input again. please help me solve it

while( (box != 'a')| (box != 'b')|(box != 'c' )){ printf("please enter a correct name of box "); scanf(" %c", &box); }

14th Apr 2021, 11:50 AM
Coder
Coder - avatar
2 Answers
+ 1
Try to use && in between the expressions instead. Not sure what you're trying to do here cause it's only a partial code,
14th Apr 2021, 12:18 PM
Ipang
+ 1
Try loop with if condition While(...) { If (your expression with or operator) Statements Else Scanf(); }
14th Apr 2021, 3:07 PM
A S Raghuvanshi
A S Raghuvanshi - avatar