Computer Science, asked by deshpandegeetar, 4 months ago

II. Write the output of the given program codes:-
1. int a=50, b=60, c=70;
c+=(a>0 && a<50)?++a: a/b;
System.out.println(c);​

Answers

Answered by terrificdatabytes
0

Answer:

Order of Execution of print function is not from left to right , as often misunderstood. It depends upon the arguments , sub-expression and the compiler.

In this particular case , there are two logical operators in the argument of the print function. These are “AND” & “OR”. “AND” operation has higher precedence than “OR” operation, so it is evaluated first.

Hence, print function is evaluated in the following order:

print(a>45 or b>50 and c>10) #and operation is executed first

print(a>45 or (0)) #Since b is not greater than 50 and c is not greater than 0

print(1 or 0) # Since a is 50 and is greater than 45

print(1)

Answer : 1

Similar questions