C Program to find the sum of first n even numbers using for loop

Program

#include<stdio.h>
void main()
{
	int n, i, even_sum;
	even_sum = 0;
	printf("Enter the value of n:\t");
	scanf("%d", &n);
	for(i = 1; i <= n; i++)
	{
		if((i %2) == 0)
		{
			even_sum = even_sum + i;
		}
	}
	printf("Sum of even series from 1 to %d is %d\n", n, even_sum);
}

Output

Enter the value of n:	20
Sum of even series from 1 to 20 is 110