Let us now try comparing two numbers by letting the user input two different numbers and say "Greater" if the first inputted number is greater than the second one, and "Lesser" if it’s the other way around.
Let's go!
Input
A line containing two different numbers separated by a space.
1.2·1.02
Output
A line containing a string.
Greater
#include <iostream>
using namespace std;
int main()
{
double x,y;
cout<<"\nEnter two numbers: ";
cin>>x>>y;
if(x>y){
cout<<"\nGreater";
}
else if(x<y){
cout<<"\nLesser";
}
return 0;
}
Comments
Leave a comment