Advertisement
Sabbir-bin

sum of (1+2+3...........99+100)

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