下列程序的功能:对输入的一行字符中的数字字符的字面值累加,输出此累加和,请填空。 #include<stdio.h> #include<ctype.h> main() { char c; int a,s=0; while(______) if(isdig

admin2010-12-10  18

问题 下列程序的功能:对输入的一行字符中的数字字符的字面值累加,输出此累加和,请填空。
#include<stdio.h>
#include<ctype.h>
main()
{  char c;
int a,s=0;
while(______)
if(isdigit(c))
{a=c-’0’;s+=a;}
printf("s=%d",s);
}

选项 A、(c=getchar())!=’\n’

答案

解析  分析题目可知,程序中运用函数c=getchar()从标准输入设备读取下一个字符,而且是一行的字符(即没有换行),所以条件为(c=getchar())!=’\n’。
转载请注明原文地址:https://kaotiyun.com/show/n2Pp777K
0

最新回复(0)