就业数据资源平台
当前位置:首页 > C语言程序设计
全国计算机等级考试C语言考试程序改错题(1)

在考生文件夹下,给定程序MODI.C的功能是:


求一维数组a中所有元素的平均值,结果保留两位小数。


例如,当一维数组a中的元素为:10,4,2,7,3,12,5,34,5,9


程序的输出应为:The aver is: 9.10 。


 


#include


#include


 void main()


  {


    int a[10]={10,4,2,7,3,12,5,34,5,9},i;








float aver,s;


  /************found************/


    int aver,s;


  /************found************/








s=a[0];


    s = 0;


    for ( i=1; i<10; i++)


      s += a[i];


    aver =  s / i;


    printf("The aver is: %.2f\n", aver);


}


 

就业数据资源平台