+ 4
Why this don't have output?
6 Réponses
+ 3
There are 2 curly brackets at the end of if(18==age) one of them should be moved to after the last else statement
+ 3
if (age >= 16){
if (age == 18){
Console.WriteLine("He is 18 years old");
}
} ^ //wrong bracket
else{
Console.WriteLine("He is 16 years old");}
}
》//where it should be placed
+ 3
This can be done more simply without nested if statements.
Here is a demo:
if(age>20) {
Console.WriteLine("Adult");
} else if(age==18) {
Console.WriteLine("He is 18 years old");
} else if(age==16) {
Console.WriteLine("He is 16 years old");
} else {
Console.WriteLine("He is a teenager");
}
0
uu
0
It is better if you can drop in spaces between curly brackets and format the code.It will be helpful in debugging
- 2
Due to poor logic