Advertisement
mustahidhasan

sum of 0 to n

Feb 20th, 2019
97
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.  
  3. int main(){
  4.  
  5.  
  6.     int i, n, sum = 0;
  7.     scanf("%d", &n);
  8.  
  9.     for(i = 0; i <= n; i = i+2){
  10.  
  11.             sum = sum + i;
  12.     }
  13.      printf("%d", sum);
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement