+ 3
If you want to check the age , better use a switch statement
0
You can use the nested way, such as this:
if (age > 18)
{
//code
}
else
{
if (age == 18)
{
//code
}
else
{
if (age < 18)
{
//code
}
}
}
Or you can choose to use multiple if-else statements in such a way that:
if (age > 18)
{
//code
}
else if (age == 18)
{
//code
}
else if (age < 18)
{
//code
}
Both options work exactly the same, and are both viable. If you want to be picky, opt for the latter method, idealy.
And to answer your question, these if-else statements can be used in conjunction as many times as you like, no limit.