pkbagchi

timus_1068

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