codeGK
Code it ALL
C If Else - CodeGK
♦ C If Else

♣ About If Else in C

if, else are conditional execution statements, that is only one of them is executed in the flow.
Possible conditionals resulting to boolean values are:-
  • Greater Than: a > b
  • Greater Than or Equal to: a >= b
  • Less Than: a < b
  • Less Than or Equal to: a <= b
  • Equal to: a == b
  • Not Equal to: a != b

♣ Example1: IF in C

If a particular statement is satisfied then the corresponding if statement is executed.
In this example, marks are compared.
Example
Input:
Output:

♣ Example2: ELSE in C

If the given if statements holds False then the else condition is executed.
In this example, marks are compared with additional keyword else.
Example
Input:
Output:

♣ Example3: Else-If in C

If the given if statements holds False and else if condition holds true then the else if condition is executed.
In this example, marks are compared with additional keywords if,else-if, and else.
Example
Input:
Output:
Prev_LessonNext_Lesson
C If Else