A_farha

4

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