Computer Applications
Predict the output:
int a=6,b=5;
a += a++ % b++ *a + b++* --b;
Java
Java Operators
90 Likes
Answer
a = 49
Working
a += a++ % b++ *a + b++* --b => a = a + (a++ % b++ *a + b++* --b) => a = 6 + (6 % 5 * 7 + 6 * 6) // % and * will be applied first due to higher precedence => a = 6 + (7 + 36) => a = 49
Answered By
46 Likes
Related Questions
Give the output of the snippet:
int a=10,b=12; if(a==10&&b<=12) a--; else ++b; System.out.println(a + "and" +b);
Write the Java expression for the following:
Rewrite the snippet using Ternary operators:
if(a<b) { c=(a+b); } else { c=(a-b); }
Give the output of the snippet:
int p = 9; while (p<=15) { p++; if(p== 10) continue; System.out.println(p); }