while循环基础问题
#include <stdio.h>int main(void)
{
long num;
long sum = 0L;
int status;
printf("Please enter an integer to be summed. ");
printf("q to quit): ");
status = scanf("%ld", &num);
while(status == 0)
{
sum = sum + num;
printf("Please enter next integer (q to quit): ");
status = scanf("%ld", &num);
}
printf("Those integers sum to %ld.\n", sum);
return 0;
}
问题1:初始化sum = 0为什么要加个L?
问题2:scanf()输入完一个数后,会有返回值?那这个返回值在那里?
问题3:status = scanf("%ld", &num); num得到值后又赋给status?