+ 1
please anyone clarify that why this code give "No Output"
4 Réponses
+ 4
Hey kumar bittu , just you need to keep this statement
System.out.println("biggest number is " + reasult);
out of else block {} , you kept this statement in else block as condition a>b is true it enters into if block rather than else block so that's why there's no output
Code is here:
public class Program
{
public static void main(String[] args) {
int a=8;
int b=5;
int c=12;
int reasult= 0;
if (a>b) {
if (a>c) {
reasult=a;
} else{
reasult=c;
}
} else{
if (b>c){
reasult=b;
} else {
reasult=c;
}
}
System.out.println("biggest number is " + reasult);
}
}
+ 1
As a is bigger then b the first condition evaluates to true and you didn't put any print statement in it or at least out of all conditions.
+ 1
But when first condition is true it goes nested inner if block, if inner if block is not true than code needs to exicute nested else and print c as a reasult...
+ 1
kumar bittu Write Print Statement out of first if statement else because if statement evaluates true so your print statement which is inside else doesn't runs
Try this :
https://code.sololearn.com/cL80PtWftlId/?ref=app