deafninja
deafninja

Reputation: 23

Breaking a while loop with more than one character in c programming

How do i get this snippet of code to break the while loop with both "a" and "A"? I can't get the OR function right. Thanks in advance for the help.

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

Upvotes: 1

Views: 175

Answers (1)

lulle2007200
lulle2007200

Reputation: 927

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')

Upvotes: 1

Related Questions