6 if and else statements
if-else statement should have the following format:
if (condition){ /* Conditions for operation */
statements;
}
if (condition) {/*Conditions for performing operations. */
statements;
} else {/*Conditions for performing operations*/
statements;
}
if (condition) {/*Conditions for performing operations*/
statements;
} else if (condition) {/*Conditions for performing operations*/
statements;
} else{ /*Conditions for operation*/
statements;
}
Note: if statements are always enclosed in "{" and "}" to avoid using the following error-prone formats:
if (condition) //Avoid this way of writing, he ignores "{}"
statement;
The comment format can also be written in the following way
if (condition) {
/*Conditions for operation*/
statements;
} else {
/*Conditions for operation*/
statements;
}
As long as you can clearly describe the relationship between the branches, you can write comments anywhere