The following C code was written to find the minimum of a set of
positive integers that a user enters from the keyboard. The user signifies
the end of the set by entering the value −1. Once all the numbers have
been entered and processed, the program outputs the minimum.
However, the code contains an error. Identify and suggest ways to fix
the error. Use a source-level debugger, if needed, to find it.
#include
int main(void)
{
int smallestNumber = 0;
int nextInput;
// Get the first input number
scanf("%d", &nextInput);
// Keep reading inputs until user enters -1
while (nextInput != -1) {
if (nextInput
smallestNumber = nextInput;
scanf("%d", &nextInput);
}
printf("The smallest number is %d\n", smallestNumber);
}