有以下程序:
#include<stdio.h>
double f(double x);
main()
{double a=0; int i;
for(i=0; i<30; i+=10) a+=f((double)i);
printf("%5.0f\n", a);
}
double f(double x)
{return x*x+1; }
程序运行后的输出结果是
此题是一个简单的函数调用, 当 i=0 并且 i<30, 执行 i+=10, 并且调用函数 f, 所以当 i=0 时, 结果为 1; 当 i=10 时, 结果为 101; 当 i=20 时, 结果为 401, 所以a=1+101+401=503。