Introduction
The flow of program control using the given condition whether the condition is “TRUE” or “FALSE”. Some keyword are given below which are used for selection statements:
- If
- Else
- Switch
- Case
- Break
- Default
Here we will discuss if else statement.
Definition
The if statement runs when the condition is “TRUE”, while when the condition is “FALSE” the else statement runs.
Example
- if(statement==true)
- {
-
- }
- else
- {
-
- }
Simple Code
- static void Main(string[] args)
- {
- int a = 2;
- int b = 3;
- int c;
- c = a + b;
- if (c == 5)
- {
- Console.Write("Condition True..");
- }
- else
- {
- Console.Write("conditiion false..");
- }
- Console.ReadKey();
- }