Answer: Read two integers and compare them with an if – else if – else ladder.
Logic: if a > b, a is greater; else if a < b, b is greater; otherwise both are equal.
Program:
#include <stdio.h>
int main()
{
int a, b;
printf("Enter two integers: ");
scanf("%d %d", &a, &b);
if (a > b)
printf("%d is greater than %d\n", a, b);
else if (a < b)
printf("%d is greater than %d\n", b, a);
else
printf("Both numbers are equal\n");
return 0;
}Sample output (actual run):
Enter two integers: 15 8
15 is greater than 8Enter two integers: 4 4
Both numbers are equal