为什么得不到正确的结果

# include<stdio.h>

int main()

{

int n,i;

double sum,grade,count;

printf("entern:\n");

scanf("%d",&n);

sum = 0;

count = 0;

for(i=1;i<=n;i++){

printf("enter grade#%d:",i);

scanf("%d",&grade);

sum = sum+grade;

if(grade<60)

count++;

}

printf("average=%.2f\n",sum/n);

printf("count=%d\n",count);

return 0;

}

编译过了 没有语法问题 但是最后运行的的结果不正确 都是零


小王同学2015
浏览 1386回答 1
1回答

asd8532

# include<stdio.h> int main() { int n,i; double sum,grade,count; printf("entern:\n"); scanf("%d",&n); sum = 0; count = 0; for(i=1;i<=n;i++){ printf("enter grade#%d:",i); scanf("%lf",&grade);//%d改成%lf sum = sum+grade; printf("sum=%f\n",grade); if(grade<60) count++; } printf("average=%.2f\n",sum/n); printf("count=%lf\n",count);//这里也是改成%lf return 0; }
打开App,查看更多内容
随时随地看视频慕课网APP