Write a program in c++ to display greatest of two input number using IF... ELSE | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Write a program in c++ to display greatest of two input number using IF... ELSE

20th Nov 2016, 1:46 PM
Aniket Deshmukh
3 Answers
+ 1
#include <iostream> using namespace std; int main() { int x,y; cout<<"Enter the two numbers"<<endl; cin>>x>>y; if((x-y)>0) { cout<<x<<" is greater"<<endl; } else { cout<<y<<" is greater"<<endl; } getch(); return 0; }
21st Nov 2016, 1:12 AM
Prarabdh Garg
Prarabdh Garg - avatar
0
#include <iostream> using namespace std; int main() { int x,y; cout<<"Enter the two numbers"<<endl; cin>>x>>y; if(x>y) { cout<<x<<" is greater"<<endl; } else { cout<<y<<" is greater"<<endl; } getch(); return 0; }
20th Nov 2016, 2:06 PM
Prarabdh Garg
Prarabdh Garg - avatar
0
#include<iostream> using namespace std; int main() { int a,b; cout<<"Enter the two numbers:-"; cin>>a>>b; if(a>b) { Cout<<"a is grater"; } else { cout<<"b is greater"; } return 0; }
20th Nov 2016, 4:26 PM
Ajeet Singh
Ajeet Singh - avatar