Computer Applications
Give the output of the program snippet.
int a = 10, b =12;
if(a>=10)
a++;
else
++b;
System.out.println(" a = " + a + " and b = " +b);
Java
Java Operators
152 Likes
Answer
a = 11 and b = 12
Working
The condition if(a>=10)
is true so a++ increments a to 11. b remains the same.
Answered By
75 Likes
Related Questions
Rewrite the following using ternary operator.
if(income<=100000) tax = 0; else tax = (0.1*income);
Rewrite the following using ternary operator.
if(p>5000) d = p*5/100; else d = 2*p/100;
Evaluate the following expressions, if the values of the variables are a = 2, b = 3 and c = 3
i. a - (b++) * (--c)
ii. a * (++b) %c
If a = 5, b = 9, calculate the value of:
a += a++ - ++b + a