# C Program to Read Two Integer and Find Which is Greater

In this article, we will learn how to find the large number between two numbers asked from the user. To write this program, we will need some basic concept of C programming (eg: if-else conditionals)

## Algorithm – Finding the Large Number from Two Input Number

• Declare two integer variables called num1, and num2.
• Take 2 input numbers and keep them in the num1 and num2 variable using scanf() function.
• Compare between the two numbers and determine which is large and which is small using the C if-else statement.
• Display the indication which is the large and small number and who is greater than another.

## C Program to Read Two Integer and Find Which is Greater

``````#include <stdio.h>
int main() {
int num1, num2;

printf("Enter number 1: ");
scanf("%d", &num1);
printf("Enter number 2: ");
scanf("%d", &num2);

if(num1 > num2) {
printf("%d is greater than %d\n", num1, num2);
} else if(num2 > num1) {
printf("%d is greater than %d\n", num2, num1);
} else {
printf("%d is equal to %d\n", num1, num2);
}
return 0;
}``````
1. Save the file with .c file extension and run the program using your favorite IDE. You can see the output. Check the test case given below;
Sample Input Sample Output
Enter number 1: 35
Enter number 2: 66
66 is greater than 35
Enter number 1: 55
Enter number 2: 10
55 is greater than 10
Enter number 1: 9
Enter number 2: 9
9 is equal to 9

## General Learning Output (GLO)

• Declaration of C main function.
• declaration of integer variable.
• The syntax, uses, and function of if, else if, else statement in the program.
• Printing to the console depending on the if-else conditions.

Happy Coding 🙂