Predict the output of the following snippets. (2)
val = 1600;
int val, sum, n=550;
sum=n+val>1750?400:200;
System.out.println(sum);
Answers
Answered by
1
Question:-
- To find the output of the following snippet
int val = 1600;
int sum, n=550;
sum=n+val>1750?400:200;
System.out.println(sum);
_____________________
Output:-
400
_______________________
Answer with Explaination:-
Initially, val =1600 and n=550
sum=n+val>1750?400:200;
n+val=1600+550=2150
So, 2150 >1750.....True
So,sum will get 400
Hence the correct output is 400.
Similar questions
Geography,
1 month ago
Chemistry,
1 month ago
Computer Science,
1 month ago
Political Science,
2 months ago
English,
8 months ago
Political Science,
8 months ago