下面的C语言程序代码从用户键盘输入的所有正整数中找出最小。用户通过输人“-1”表示输入结束。数据输入完毕并处理完之后,输出最小值。但是代码中存在一个错误,试找出错误并阐述解决思路和方法。如果需要的话你可以用一个源码级调试工具来帮助查找错误。
include<stdio.h> int main() { int smallestNumber=0; int intnextInput; scanf("%d",&nextInput); while(nextInput !=-1){ if(nextInput<smallestNumber) smallestNumber=nextInput; scanf("%d",&nextInput); } printf("The smallest number is %d\n",smallestNumber); }