Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int n, i=1, Sum=0;
- printf("Enter the number:");
- scanf("%d", &n);
- while (i<=n)
- {
- if(i%2==0)
- Sum=Sum+i;
- i++;
- }
- printf("Sum of all even numbers=%d", Sum);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement