334 views
0 votes
0 votes
main()
{

int a = 1;
   int b = 1;
   int c = a || b--;
   
   printf("a = %d b=%d\n",a,b);
 
   return 0;
}

4 Answers

2 votes
2 votes
Short circuit rule will be follow here

When 1st condition is true, it will not check for any other condition

So, a=1 is true, that is why condition for b will not be checked

Answer will be a=1,b=1 will be printed here
0 votes
0 votes
due to OR if a=1 then no need to check b............
0 votes
0 votes
Compiler see if the first condition is true than it does not check for the second condition that's why not decrement
0 votes
0 votes

In C, there are 4 operators which clearly specify the order of evaluation of operands

1) logical AND (&&) :- evaluation order is left to right and if left operand is false then second operand is not evaluated

2) logical OR (||) :- evaluation order is left to right and if left operand is true then second operand is not evaluated

3) Ternary Operator (e1?e2:e3): evaluation order is left to right and only one of the operands (e2 or e3) evaluated based on e1

4) Comma Operator(,) : evaluation order is left to right

Related questions

1 votes
1 votes
0 answers
1
namanom1 asked Jul 12, 2016
450 views
In the given program, when compiled in Dev c++ and executed, the main does not terminate. is there any explanation to this? ( page 16, Dennis Ritchie)#include<stdio.h mai...
0 votes
0 votes
1 answer
3
2 votes
2 votes
3 answers
4
Laahithyaa VS asked Sep 9, 2023
935 views
. What will be the value returned by the following function, when it is called with 11?recur (int num){if ((num / 2)! = 0 ) return (recur (num/2) *10+num%2);else return 1...