Advertisement
sabbirarif

Sum and Average of 1 to 100 using For Loop

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