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
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
Math,
1 month ago
World Languages,
1 month ago
Biology,
1 month ago
Accountancy,
3 months ago
Sociology,
3 months ago
Hindi,
9 months ago
English,
9 months ago