C Programming Code Examples C > If Else and Switch Case Code Examples Program to find maximum between two numbers using if...else Program to find maximum between two numbers using if...else Finding maximum in general is comparison of two numbers. In C programming we compare two quantities using relational operator. We use either > or < operator to compare two numbers (or other primitive types). Relational operator evaluates 1 (true) or 0 (false) depending on condition. We can write expression to find maximum between j1 and j2 as j1 > j2. The expression j1 > j2 evaluate 1 if j1 is greater than j2, otherwise evaluates 0. After finding maximum, we need to execute some action based on the maximum i.e. print the maximum number. In C if...else provides ability to execute an action based on condition. So we will make use of relational operator along with if...else to find maximum. Below is step by step descriptive logic to find maximum. Input two numbers from user. Store it in some variable say j1 and j2. Check if(j1 > j2) then print j1 is maximum. Check if(j2 > j1) then print j2 is maximum. Check if(j1 == j2) then both the numbers are equal. #include <stdio.h> int main() { int j1, j2; /* Input two numbers from user */ printf("Enter two numbers: "); scanf("%d%d", &j1, &j2); /* Compare j1 with j2 */ if(j1 > j2) { /* True part means j1 > j2 */ printf("%d is maximum", j1); } else { /* False part means j1 < j2 */ printf("%d is maximum", j2); } return 0; }