if statement
Syntax:
if (condition) {
// code to execute if the condition is true
} else {
// code to execute if the condition is false
}
Explanation:
- The statement inside the if block are executed only when condition is true, otherwise not.
- If we want to execute only one statement when condition is true, then braces ({}) can be removed.
- In general, we should not omit the braces even if, there is a single statement to execute.
Sample code:
Output:
Answer the following Two questions: