what will be the new value of k from : k=(k%3==0)? (k*3) :(k+3) if k=15 (ii) k =0
answer me fast
Answers
Answered by
1
Answer:
k = 15
45
k = 0
0
Explanation:
The expression, (k%3==0)? (k*3) :(k+3), checks if k is divisible by 3 or not, if yes then evaluate to (k * 3) else evaluate to (k + 3)
15 is divisible by 3, so k = 15 * 3
0 is also divisible by 3, because when you divide 0 by 3 you get 0 remainder which is the definition of divisibility, so k = 0
Answered by
4
Answer:
The given expression is a ternary operator
Solution:-
- when k=15
Since the condition is true, k will store 45 as it's value.
- when k=0
Here, again the condition is true, k will store 0 as it's new value
Final Answer:-
- When k=15,
k=45
- When k=0,
k=0
Similar questions