A C program to find sum of even numbers between 1 to N using for loop

//A C program to find sum of even numbers between 1 to N using for loop 

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i, n, sum=0;
printf("Enter tne number: ");
scanf("%d", &n);
for(i=2; i<=n; i+=2)
{
sum += i;
}
printf("Sum of all even number between 1 to %d = %d", n, sum);
getch();
}

Output:


A C program to find sum of even numbers between 1 to N using for loop , my knowledge to you dude








Post a Comment

0 Comments