+ 2

how can to compare three no. and tell which one is greater

27th Jul 2016, 6:21 PM
Abhishek Prasad
Abhishek Prasad - avatar
3 odpowiedzi
+ 2
not using if and else #include <iostream. h> #include <conio. h> void main () { int a,b,c; cout<<"enter any three no.s "<<endl; cin>>a>>b>>c; a=(a>b)?a:b;c=(c>a)?c:a; cout <<"/ngreater no is/t"<<c; gatch (); }
27th Jul 2016, 6:43 PM
Abhishek Prasad
Abhishek Prasad - avatar
0
using if and AND #include <iostream.h> using namespace std; int main() { int a,b,c; cout<<"Enter first number"<<endl; cin>>a; cout<<"Enter second number"<<endl; cin>>b; cout<<"Enter third number"<<endl; cin>>c; if (a>b && a>c) { cout<<"A is greatest"; } else if (b>a && b>c) { cout<<"B is greatest"; } else if (c>a && c>b) { cout<<"C is greatest"; } else cout<<"Either they are equal or non numeric"; } I think this is it. if it is wrong someone might correct me since there wont be much to write . Good luck and have fun coding!
27th Jul 2016, 6:35 PM
Vlad Cranga
Vlad Cranga - avatar
0
thanks
27th Jul 2016, 6:37 PM
Abhishek Prasad
Abhishek Prasad - avatar