+ 3
What is nested if ?
how can it work
3 odpowiedzi
+ 15
if()
{ if()
{ if()
{ if()
{}
}
}
}
this is called nested if
i.e.,if within if condition
+ 2
if inside if
+ 1
it works by checking the condition of the first if, and if true enters the code block, which can have its own (nested) ifs inside, can go as deep as it needs to, 3-4 nested ifs are quite common, however try not to get too many levels deep with nested ifs, makes the code much harder to read