Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //C program to find sum of even numbers between 1 to n
- #include<stdio.h>
- int main(){
- int n,i,sum=0;
- printf("ENTER THE INTEGER :");
- scanf("%d",&n);
- for(i=1;i<=n ;i++){
- if(i%2 == 0){sum+=i;}
- }
- printf("Sum of even numbers between 1 to %d = %d \n",n,sum );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment