Explanation of Program:
The first ‘if’ loop will assign the first value entered by the user to the smallest and largest variable.
The subsequent if loop will check the next number entered and if it is smaller than the previous value, it will be assigned to ‘smallest’ variable, and if greater than the previous value it will be assigned to 'largest' variable.
After the end of the loop, the values of the ‘smallest’ and ‘largest’ variable are printed.
OUTPUT:
Enter the number: 10
Enter the number: 5
Enter the number: 22
Enter the number: 50
Enter the number: 7
The smallest number is 5
The largest number is 50