if Statement
if Statement
Decision-making involves evaluating a condition to a Boolean value and making a decision based on it. The basic idea revolves around executing the block of code whose condition evaluates to true. Below are the types of decision-making statements:
- if statement
- if…..else statement
- if…..else if statement
- nested if statements
- switch statement
if statement:
In a simple if statement, a block of code inside the if statement is only executed if the condition evaluates to true.
Syntax:
Output:
Example:
Output: