First, let's look at the order of operations. The logical AND operator && has higher precedence than the logcial OR operator ||, so the expression parses as follows:

c = a++ || (++b && ++c);

Next, both || and && are short circut operators. This means that the left has side is evaluated first, and if the result can be determined solely from that then the right hand side is not evaluated.

So a starts out with the value 10. a++ evaluates to the current value (10) while incrementing a as a side effect. This means the value 10 is the left hand side of ||. Because this is a non-zero value, the value of the entire expression is 1 and the right hand side ++b && ++c is not evaluated. Then this result is assigned to 1.

So the end result is a is incremented to 11, c is assigned 1 because that is the value of the || expression, and b is unchanged.

Answer from dbush on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ c โ€บ c_operators_logical.php
C Logical Operators
Remember: in C, 1 means true and 0 means false. Logical operators often become easier to understand once you start using them inside if statements, which you will learn about in the upcoming chapters.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ logical-operators-in-c
C Logical Operators - GeeksforGeeks
Logical operators in C are used to combine multiple conditions/constraints. Logical Operators returns either 0 or 1, it depends on whether the expression result is true or false.
Published ย  October 19, 2025
Discussions

Using logical operators on integers in C - Stack Overflow
Logical OR and Logical AND operator on integers in C Can you explain me why the values of a,b,c are 11,10,1 respectively. Why the value of b remains same as 10? #include int main()... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Logical Operators in C - Stack Overflow
I am having trouble trying to understand how logical operators work in C. I already understand how the bit-level operators work, and I also know that logical operators treat nonzero arguments as More on stackoverflow.com
๐ŸŒ stackoverflow.com
c - Using logical operators with macros - Stack Overflow
I have a piece of code which I want to include if either of two macros are defined #ifdef MACRO1 || MACRO2 void foo() { } #endif How do I accomplish this in C? More on stackoverflow.com
๐ŸŒ stackoverflow.com
Bitwise operators v.s. Logical operators. What's the difference?
Logical operators apply to one or two operands, each of which may be true or false. A value is considered to be false if it is zero, and true if it isn't. If the result of the logical operation is true, it evaluates to 1. If it's false, it evaluates to 0. For instance, 2 && 0 == 0, and 2 && 1 == 1. Bitwise operators apply to each of the bits of one or two operands. A bit is considered to be true if it's set to 1 and false if it's set to 0. The operation evaluates to a value where the bit in any given position is the result of applying the comparison to the bits in the same position in the operands. For instance, 2 & 3 == 0...0010b & 0...0011b == 0...0010b == 2, and 2 & 4 == 0...0010b & 0...0100b == 0...0000b == 0: 00000010 & 00000011 -------- 00000010 00000010 & 00000100 -------- 00000000 As for the logical NOT, it simply transforms any nonzero value (true) into 0 (false), and zero (false) into 1 (true). A consequence of this is that applying a logical NOT to the result of a logical NOT (as in !!value) changes any nonzero original values into 1, and leaves 0 unchanged. More on reddit.com
๐ŸŒ r/C_Programming
6
2
August 18, 2018
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ home โ€บ cprogramming โ€บ c logical operators
C Logical Operators
June 10, 2012 - The logical AND operator (&&) and the logical OR operator (||) are both binary in nature (require two operands). The logical NOT operator (!) is a unary operator. Since C treats "0" as False and any non-zero number as True, any operand to a ...
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ cpp โ€บ c-language โ€บ c-logical-operators
C logical operators | Microsoft Learn
April 7, 2022 - The following examples illustrate the logical operators: int w, x, y, z; if ( x < y && y < z ) printf( "x is less than z\n" ); In this example, the printf function is called to print a message if x is less than y and y is less than z. If x is greater than y, the second operand (y < z) isn't evaluated and nothing is printed.
๐ŸŒ
Cppreference
en.cppreference.com โ€บ w โ€บ c โ€บ language โ€บ operator_logical.html
Logical operators - cppreference.com
#include <stdbool.h> #include <stdio.h> #include <ctype.h> int main(void) { bool b = !(2+2 == 4); // not true printf("!(2+2==4) = %s\n", b ? "true" : "false"); int n = isspace('a'); // non-zero if 'a' is a space, zero otherwise int x = !!n; // "bang-bang", common C idiom for mapping integers to [0,1] // (all non-zero values become 1) char *a[2] = {"non-space", "space"}; puts(a[x]); // now x can be safely used as an index to array of 2 strings } ... The logical-AND operator has type int and the value 1 if both lhs and rhs compare unequal to zero.
๐ŸŒ
R-bloggers
r-bloggers.com โ€บ r bloggers โ€บ understanding logical operators in c programming
Understanding Logical Operators in C Programming | R-bloggers
November 13, 2024 - Introduction to Logical Operators Logical operators are fundamental building blocks in C programming that allow us to make decisions and control program flow based on multiple conditions. These operators work with Boolean values (true/false) an...
๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ Operators_in_C_and_C++
Operators in C and C++ - Wikipedia
1 month ago - Instead & | had different meaning depending on whether they are used in a 'truth-value context' (i.e. when a Boolean value was expected, for example in if (a==b & c) {...} it behaved as a logical operator, but in c = a & b it behaved as a bitwise one).
Find elsewhere
Top answer
1 of 3
3

First, let's look at the order of operations. The logical AND operator && has higher precedence than the logcial OR operator ||, so the expression parses as follows:

c = a++ || (++b && ++c);

Next, both || and && are short circut operators. This means that the left has side is evaluated first, and if the result can be determined solely from that then the right hand side is not evaluated.

So a starts out with the value 10. a++ evaluates to the current value (10) while incrementing a as a side effect. This means the value 10 is the left hand side of ||. Because this is a non-zero value, the value of the entire expression is 1 and the right hand side ++b && ++c is not evaluated. Then this result is assigned to 1.

So the end result is a is incremented to 11, c is assigned 1 because that is the value of the || expression, and b is unchanged.

2 of 3
1

This expression

c = a++ || ++b && ++c;

can be equivalently rewritten like

c = ( a++ ) || ( ++b && ++c );

As the expression a++ is not equal to 0 then the second sub-expression ( ++b && ++c ) is not evaluated.

The value of the logical operator || and && is either 1 (true) or 0.

From the C Standard (6.5.14 Logical OR operator)

3 The || operator shall yield 1 if either of its operands compare unequal to 0; otherwise, it yields 0. The result has type int.

and

4 Unlike the bitwise | operator, the || operator guarantees left-to-right evaluation; if the second operand is evaluated, there is a sequence point between the evaluations of the first and second operands. If the first operand compares unequal to 0, the second operand is not evaluated.

So c gets the value 1 and a was increased.

๐ŸŒ
Steve's Data Tips and Tricks
spsanderson.com โ€บ steveondata โ€บ posts โ€บ 2024-11-13
Understanding Logical Operators in C Programming โ€“ Steveโ€™s Data Tips and Tricks
November 13, 2024 - Master logical operators in C programming (&&, ||, !) with comprehensive examples, truth tables, and best practices. Perfect guide for beginners to advance their C skills.
๐ŸŒ
W3Schools
w3schools.com โ€บ c โ€บ c_operators.php
C Operators
if else else if Short Hand If Nested If Logical Operators Real-Life Examples Code Challenge C Switch ... C Functions C Function Parameters C Scope C Function Declaration C Functions Challenge C Math Functions C Inline Functions C Recursion C Function Pointers
๐ŸŒ
Microchip Developer Help
developerhelp.microchip.com โ€บ xwiki โ€บ bin โ€บ view โ€บ software-tools โ€บ compilers โ€บ c-programming โ€บ operators โ€บ logical
C Programming Logical Operators - Developer Help
August 26, 2025 - They can be used to selectively execute code based on the outcome of the condition. In the first example, if both x and y have non-zero values, then the result of the expression will be non-zero (TRUE - 1). If either or both x and y are zero, then the result is 0 (FALSE).
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ c-operator-logic-operators-in-c-programming
C Operator โ€“ Logic Operators in C Programming
March 8, 2023 - This operator reverses the logical value of the operand โ€“ it changes true to false and false to true. Bitwise operators like the NOT(~) operator, which changes each 0 bit to 1 and each 1 bit to 0. Binary operators operate on two operands. Some of the binary operators in C are:
๐ŸŒ
Unstop
unstop.com โ€บ home โ€บ blog โ€บ logical operators in c & truth tables (+ code examples)
Logical Operators In C & Truth Tables (+ Code Examples)
September 2, 2024 - Logical operators in C include AND (&&), OR (||), NOT (!), and XOR (^). They perform comparisons/ logical operations on operands and return boolean values.
๐ŸŒ
StudySmarter
studysmarter.co.uk โ€บ computer science โ€บ computer programming โ€บ logical operators in c
Logical Operators in C: Examples, Bitwise, Precedence
Understanding the types of logical operators and how they function will enhance your ability to write efficient and effective code in the C programming language. There are three main types of logical operators in C: AND, OR, and NOT. These operators allow you to compare expressions and make ...
๐ŸŒ
The Knowledge Academy
theknowledgeacademy.com โ€บ blog โ€บ operators-in-c-programming
Operators in C Programming: Explained with Examples
4 weeks ago - In C Programming, an operator is a symbol that tells the compiler to perform specific mathematical, relational, or logical operations on variables and values to generate a result, as explained in the C Programming Examples Guide.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ home โ€บ cprogramming โ€บ c operators
C Operators
June 10, 2012 - The most common logical operators are AND (&&), OR(||), and NOT (!). Logical operators are also binary operators. ... We will discuss more about Logical Operators in C in a subsequent chapter.
๐ŸŒ
EmbeTronicX
embetronicx.com โ€บ tutorials โ€บ p_language โ€บ c โ€บ operators-in-c
Operators in C Programming Language | Types and Examples
August 26, 2023 - Let us consider, suppose if you have a value of a = 50, b = 10, c; then you will get, c = a > b which is true. So, 1 will be stored in the c. And if b = 100 then it will be as false and c will be having 0. So the concept in this logical operator says that it depends on a > b whether it is true ...
๐ŸŒ
Flowcode
flowcode.co.uk โ€บ courses โ€บ C4PICs โ€บ Course Files โ€บ C_programming โ€บ Conditional_statements โ€บ Logical_operators.html
C4PICs - Logical operators
These work like +, -, * or / but they produce either 0 or 1 as a result depending on whether or not the result of the logical expression is true or false. For example: ... The operator > means "less than". When the compiler sees this it says "Aha, you want me to compare these two operands and return true (i.e. a non-zero value) if the comparison is true". In this case the result would be true if (and only if) the value in the variable counter is less than 99.