Can "if" statements in c have multiple conditions | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can "if" statements in c have multiple conditions

For example if (a==0, b==0, c ==1) { ...

6th Sep 2019, 2:00 PM
Omooba Emmanuel
Omooba Emmanuel - avatar
4 Answers
+ 5
Yes they can, however, you should not chain them with a comma, it would lead to only the right-most expression being decisive for the result of the entire condition. Instead, use logical operators: https://www.sololearn.com/learn/C/2925/
6th Sep 2019, 2:06 PM
Shadow
Shadow - avatar
+ 4
Use logical operator '&&' instead of commas.
6th Sep 2019, 5:42 PM
Tanish Kushwaha
Tanish Kushwaha - avatar
+ 3
Yes
6th Sep 2019, 2:04 PM
Marina Vasilyova
Marina Vasilyova - avatar
+ 3
Some challenge questions may trick you with the comma separators you used but the logical ones are most common here.
6th Sep 2019, 11:50 PM
Sonic
Sonic - avatar