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
2 ответов
+ 3
1 && 1 -> true true && 1 -> true true || 0 -> true
31st May 2020, 11:53 AM
Avinesh
Avinesh - avatar