Advertisement
Sabid2830

for loop

Oct 19th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.19 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int i,sum=0,count=0;
  5. float avg;
  6. for(i=1;i<=100;i++)
  7. {
  8. sum=sum+i;
  9. count++;
  10. avg=(float)sum/count;
  11. }
  12. printf("sum=%d\n",sum);
  13. printf("avg=%2f\n",avg);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement