Advertisement
Sabbir-bin

sum of (2+4+6...........98+100)

Dec 6th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.22 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.   int a,sum=0;
  5.    for(a=1; a<=50; a++)
  6.    {
  7.      printf("%d", 2*a);
  8.      sum=sum+(2*a);
  9.    if(a<100)
  10.    {
  11.      printf(" + ");
  12.    }
  13.    }
  14.  
  15.   printf(" = %d", sum);
  16.  
  17.   return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement