If Statements
If statements allow for selective execution of instructions. If the condition specified evaluates to true, then the following instruction/instruction block will be executed. Otherwise, the following instruction/instruction block will be skipped.
Syntax
- if(condition)
- Instruction;
- if(condition)
- {
- Instruction Block
- }
Example
- void main()
- {
- int a = 3;
- if(a==2)
- {
- printf("\nSince A=3, this won't be printed");
- }
- if(a==3)
- {
- printf("\nSince A=3, this will be printed");
- }
- }