How to evaluate the return of (if condition) when using multiple logic operators and integers | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to evaluate the return of (if condition) when using multiple logic operators and integers

While competing with a friend using (c language) here on sololearn, there wa this question: What's the output of this code? If (1 && 1 && 1 || 0) printf("a"); else printf("b"); The solution was "a".. Now I don't know what the condition returned nor why the first was chosen. Can anyone help me understand this?

31st May 2020, 11:48 AM
Sob7yy
Sob7yy - avatar
1 Answer
+ 3
1 && 1 -> true true && 1 -> true true || 0 -> true
31st May 2020, 11:53 AM
Avinesh
Avinesh - avatar