Advertisement
erfanul007

Timus 1068

Dec 26th, 2018
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int n,total=0,i;
  5. scanf("%d",&n);
  6. if(n>0){
  7. for(i=1;i<=n;i++)
  8. total=total+i;
  9. }
  10. else if(n<=0){
  11. for(i=1;i>=n;i--)
  12. total=total+i;
  13. }
  14. printf("%d\n",total);
  15. return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement