Advertisement
nahidhasan110

sum & avg while

Oct 19th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     double avg,x,y,sum=0,i;
  5.  
  6.     while(1)
  7.     {
  8.         printf("enter range: ");
  9.         scanf("%lf %lf",&x,&y);
  10.         for(i=x; i<=y; i++)
  11.         {
  12.             sum=sum+i;
  13.         }
  14.         avg=sum/y;
  15.         printf("%lf\n",sum);
  16.         printf("%lf\n",avg);
  17.     }
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement