Getting Started With C

if statement

Syntax:

if (condition) {
    // code to execute if the condition is true
} else {
    // code to execute if the condition is false
}

Explanation:

Sample code:

Program.c

Output:

output.c

Resources :

Assess Your Understanding
Answer the following Two questions:

Q1. If block always need to be assoicated with a else block?

Q2. Which of the following is an invalid if statement?