|Well, x,y,l are your three numbers. if you want more you need more variables or an array. |
I disagree. Certainly an array is a vast overkill, it involves storing many numbers which are of no interest whatsoever.
|The objective is to print out second smalest number from user input.|
Here just three numbers are of interest:
• the latest number input by the user.
• the smallest number so far.
• the second smallest number so far.
I've not fully analysed the code, but a quick observation.
statements are not correct.
For example this line has two significant errors:
First, the separate conditions should be combined with the logical and
Second, if more than one statement is to be controlled by the if condition, they need to be grouped together using braces
if (x>y && l<=y)
Those same errors occur throughout and need to be corrected as shown. There may still be logic errors - I didn't check - but the code will at least stand a chance of executing as intended.