TCS
Company
a = 16, b = 15, c = 3
if (c divides a) {
if (b > c) {
x = 1
} else {
x = 2
}
} else {
if (c divides b) {
x = 3
} else {
x = 4
}
}
Read Solution (Total 5)
-
- first condition is false and the second is correct hence x=3
- 12 years agoHelpfull: Yes(36) No(4)
- c divides b hence x=3
- 12 years agoHelpfull: Yes(7) No(1)
- c divides a gives the quotient of dividing c by a
so it returns 5
if(5) is true,the control goes to the next if statement.
if(b>c) is true .so answer is x=1
- 12 years agoHelpfull: Yes(6) No(3)
- ans will be x=1
- 12 years agoHelpfull: Yes(5) No(8)
- ans is x=1
- 12 years agoHelpfull: Yes(2) No(2)
TCS Other Question