Click here to Skip to main content
15,887,898 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
program
C
#define N 10
main()
{
int count;
float sum, average, number;
sum=0;
count=0;
printf("enter 10 numbers");
  while( count< N);
  {
     scanf("%f",&number);
     sum=sum+number;
     count=count+1;
   }
  average=sum/N;
  printf("N=%d sum=%f",N,sum);
  printf("average=%f", average);
}
Posted
Updated 29-Oct-14 7:36am
v3

1 solution

Quote:
main()
This should be:
C
int main()
(you should also, accordingly, return a integer value from the main function).

Please note: you should always check the return value of scanf, e.g.
C
if ( scanf("%f", & number) != 1 )
{
  // handle error here
}
 
Share this answer
 
Comments
Maciej Los 29-Oct-14 15:27pm    
Could it be void main()?
+5!
CPallini 29-Oct-14 16:20pm    
Yes, it could be, at least accordingly to this page:
http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/legality-of-void-main.html
By the way, thank you!
Sergey Alexandrovich Kryukov 29-Oct-14 18:12pm    
5ed.
—SA
CPallini 30-Oct-14 6:59am    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900