mdnurnobihosen

Assignment4

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