Currently my mini algorithm looks like this.
int a,b,c,max;
cout <<"Enter 3 digits: \t";
cin>>a>>b>>c;
if(a>b && a>c)
max=a;
else if(b>c && b>a)
max=b;
else
max=c;
cout <<"max: "<<max<<endl;
It works but Is there any other way to find maximum of 3 digits?
In C++11, you could do this:
It makes use of an overload of
std::maxwhich takesstd::initializer_list<T>as argument. It implies you could pass more than 3 arguments!Demo : http://ideone.com/FLifw