C Online Compiler
Example: Greatest of Three Numbers in C using If...else Ladder
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Greatest of Three Numbers in C using If...else Ladder #include <stdio.h> // It's the main function of the program int main() { int num1, num2, num3; // Step-1 Enter three integer values printf("INPUT-1: "); scanf("%d", &num1); printf("INPUT-2: "); scanf("%d", &num2); printf("INPUT-3: "); scanf("%d", &num3); // Step-2 Check if num1 is greater than both num2 and num3, num1 is the greatest if (num1 >= num2 && num1 >= num3) { printf("\nGreatest Number :: %d", num1); } // Step-3 Check if num2 is greater than both num1 and num3, num2 is the greatest else if (num2 >= num1 && num2 >= num3) { printf("\nGreatest Number :: %d", num2); } // Step-4 If above both conditions are false then, num3 is the greatest else { printf("\nGreatest Number :: %d", num3); } return 0; }
4 7 9
Output
Clear
ADVERTISEMENTS