This is a “Find Greater of Two Numbers” C program to find greater number of the two given numbers. It uses a set of simple if statements to find either first number is greater or second number. It also tells if both numbers are equal.
/* Write a C Program to input two numbers and check which is greater or both are equal using simple if statement */ #include<stdio.h> int main() { int num1, num2; printf("Enter First Number="); scanf("%d", &num1); printf("Enter 2nd Number="); scanf("%d", &num2); if(num1 > num2) printf("First Number %d is greater than Second Number %d ", num1,num2); if(num2 > num1) printf("Second Number %d is greater than First Number %d ", num2,num1); if(num1 == num2) printf("First Number %d is equal to Second Number %d ", num1,num2); return 0; }
Here is an image that shows a sample output from a sample run of the program.