Apparently the way you structured is not the best. I say this because you do not use keys us ifs, which suggests they are only for what is being displayed in the code, i.e., validate whether the three conditions are true; being, prints. Thus, the best alternative is to use the and , as already said in a comment:
IF (Condicao1 && Condicao2 && Condicao3)
Imprime(Mensagem);
However, if there are commands to be executed in case some of them are false, you structured in the correct way.
IF (Condicao1 = True) {
IF (Condicao2 = True){
IF (Condicao3 = True){
Imprime(Mensagem);
} else {
// codigo
}
} else {
//codigo
}
} else {
//código
}
In case you don’t need any "sinews", use the first form.
Related (or duplicate):Why in some if’s situations are considered bad?
– user28595
Related: What’s the difference between Switch, Case and If, Else?
– user28595
Know the logical operator and?
If (condicao1 and condicao2 and condicao3) Imprime(Mensagem)
– Woss
I do not know if using and is the most recommended. There may be cases where you do not want to validate an equality of all conditions in a unique way. I believe the switch can be the solution when you want to validate condition by condition, or the OR, depending on the case.
– user28595
It is interesting that you specify which language you use. Some languages treat relational operators
AND/OR
in mode ofshort-circuit
and thus aAND
can function as severalIF
chained, but other languages do not use this mode.– Pagotti