Nov 2, 2019 at 6:50am Nov 2, 2019 at 6:50am UTC
largest = max( { a, b, c, d, e } );
Last edited on Nov 2, 2019 at 6:50am Nov 2, 2019 at 6:50am UTC
Nov 2, 2019 at 6:54am Nov 2, 2019 at 6:54am UTC
I have to do this only using loops. That's challenging...
Nov 2, 2019 at 7:00am Nov 2, 2019 at 7:00am UTC
Well, unless you put them into an array so that your loop cycles through the index of an array, any loop method would have to pick them out of an initialiser list. Or you would have to read them one by one. Take your pick.
It's not challenging ... have a go.
Nov 2, 2019 at 7:15am Nov 2, 2019 at 7:15am UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int a,b,c,d,e,max;
cin>>a;
max=a;
cin>>b;
if (b>max)
max=b;
cin>>c;
if (c>max)
max=c;
cin>>d;
if (d>max)
max=d;
cin>>e;
if (e>max)
max=e;
Last edited on Nov 2, 2019 at 7:16am Nov 2, 2019 at 7:16am UTC
Nov 2, 2019 at 9:00am Nov 2, 2019 at 9:00am UTC
I thought you wanted to use loops?