I'm quite new to C++ and I'm doing a little assignment right now for school. Basically a program which adds the biggest and middle number when you enter 3 digits in. My program currently works but it will add the biggest and the smallest, I need it the other way around LOL.
I know my code to find the largest works (since it will find the largest no matter what order I enter it), but the code to find the 2nd largest might be my issue.
In my program, for it to find the second largest number I have:
if (num3 < largest)
largest2 = num3;
sum = largest + largest2;
I know the error is somewhere in there, but can't quite pick it out. Where did I go wrong?
Oh no, we're meant to write it so that it finds the largest number, then the 2nd largest... well basically any way so that it finds the largest and second largest. So should it be incrementally where it finds the 2nd largest, then finds one bigger than that?