44. C Program to find Sum of n Even Numbers.
How does this program work?
- In this program your going to learn about how to find Sum of n even numbers using C-Language.
Here is the code
#include <stdio.h>
int main(void)
{
//To find sum of n even numbers
int i, n, sum=0;
//Input to enter starting even number
printf("Enter a number : \n");
scanf("%d", &n);
for(i=2; i<=n; i+=2)
{
sum += i; //Addition of even numbers
}
printf("Sum of all even number between 1 to %d = %d", n, sum);
return 0;
}