You have that the wrong way around. Set the smallest and largest to the value of the first input.
Code:
smallest = largest = number; // This sets "smallest" to the value of "number",
// as well as setting "largest" to the value of "number".
Okay, let me try to break down the thought process here.
You have three variables - "smallest" which holds the smallest number entered, "largest" which holds the largest number entered, and "number" which represents the user input.
Initially, "smallest" and "largest" have no meaningful values. Nothing has been entered yet, so there are no smallest or largest values yet.
Then the user enters their very first number. Since there is only one number entered by the user at this point, you set both "smallest" and "largest" to this value. For instance, if the user enters 5, then 5 is both the smallest and largest number entered by the user at that point.
Now the user enters a second number. If this value is less than the first number, then we need to update the value of "smallest". If this value is greater than the first number, then we need to update the value of "largest". Otherwise, we don't need to update either one.
The user then enters a third number, and the process repeats.
By setting "smallest" and "largest" to the very first number when it is first entered, we have a valid basis of comparison for each subsequent number entered by the user.