C Online Compiler
Example: Greatest of Two Numbers in C using Nested If-else
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Greatest of Two Numbers in C using Nested If-else #include <stdio.h> // It's the main function of the program int main() { int number_1, number_2; // Step-1 Take two input values from the User printf("Enter First Number: "); scanf("%d", &number_1); printf("Enter Second Number: "); scanf("%d", &number_2); // Step-2 Check if the first number is Greatest if (number_1 > number_2) { printf("\nGreatest Number :: %d\n", number_1); } else { // Step-3 Check if the second number is Greatest if (number_1 < number_2) { printf("\nGreatest Number :: %d\n", number_2); } // Step-4 If the previous condition is false then both numbers are equal else { printf("\nBoth are equal number\n"); } } return 0; }
10 7
Output
Clear
ADVERTISEMENTS