为方便广大考生更好的复习2013年计算机二级C语言考试,查找考试辅导习题,来自www.examzz.com网校特提供了C语言上机预测题(填空题、改错题、编程题),更多模拟无纸化考试“计算机二级C语言模拟题”,供考生学习。
填空题
请补充fun函数,该函数的功能是求不超过给定自然数的各偶数之和。
请勿改动主函数main和其他函数中的任何内容,仅在fun函数的横线上填入所编写的若干表达式或语句。
试题程序:#include
int fun(int x)
{
int i, s;
s = ___1___;
for (i=2; ___2___; i+=2)
s += i;
return s;
}
main()
{
int n;
do
{
printf("\nPlease enter natural numbers n:");
scanf("%d", &n);
} while (n <= 0);
printf("\n2?3?1y???¨×?è?êy%dμ??÷??êy??oí?a%d\n", n, fun(n));
}
第1处填空:0
第2处填空:i<=x或x>=i