Home > front end >  Breaking a while loop with more than one character in c programming
Breaking a while loop with more than one character in c programming

Time:11-01

How to i get this snip of code to break the while loop with both "a" and "A"? cant get the OR function right. Thanks in advance for the help.

while((product = getchar()) !='a')

CodePudding user response:

If you want to break the loop when product is a or A, you need to check if product is not a and not A in your loop condition:

while((product = getchar()) !='a' && product != 'A')
  • Related