Object
Write a program to input two numbers and print the greater one.
Algorithm
- Declare integer variables a and b.
- Read a and b.
- IF a > b, then
- Write “a is greater”.
- ELSE
- Write “b is greater”.
- [End of IF-ELSE structure.]
- Exit.
Flowchart

C++ Source Code
// program 19
#include<iostream>
using namespace std;
int main()
{
int a, b;
cout << "Enter the first number: ";
cin >> a;
cout << "Enter the second number: ";
cin >> b;
if (a > b)
{
cout << "The greater number is " << a;
}
else
{
cout << "The greater number is " << b;
}
return 0;
}
C Source Code
/*program 19*/
#include<stdio.h>
int main()
{
int a, b;
printf("Enter the first number: ");
scanf("%d", &a);
printf("Enter the second number: ");
scanf("%d", &b);
if(a>b)
printf("The greater number is %d", a);
else
printf("The greater number is %d", b);
return 0;
}
Output
Enter the first number: 5
Enter the second number: 29
The greater number is 29
