Y
yuanshuaisd
#include<stdio.h>
int main()
{
int n=1;
int average;
int num;
int sum;
for(n=1;num != 9999;n++){
printf("Enter a integer:\n");
scanf("%d",&num);
sum = sum + num;
}
average = sum / n;
printf("average is %d",average);
return 0;
}
why the program end in a wrong result
int main()
{
int n=1;
int average;
int num;
int sum;
for(n=1;num != 9999;n++){
printf("Enter a integer:\n");
scanf("%d",&num);
sum = sum + num;
}
average = sum / n;
printf("average is %d",average);
return 0;
}
why the program end in a wrong result