Advertisement
RAJIBRAJU

1 whileloop.c

Jun 21st, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.19 KB | None | 0 0
  1. #include<stdio.h>
  2. int main  () {
  3. int i=2,n,sum=0;
  4. scanf("%d",&n);
  5. while(i<=n) {
  6.  
  7.     sum+=i;
  8.     i+=2;
  9. }
  10. printf("sum of all even numbers 1 to  %d= %d",n,sum ) ;
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17. return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement