Write a c program to find the sum of even numbers in the given range
#include<stdio.h>
#include<conio.h>
void main()
{
int start,end,i,sum=0;
printf("Enter the beginning and end range of number:\n");
scanf("%d%d",&start,&end);
for(i=start;i<=end;i++)
if(i%2==0)
sum=sum+i;
printf("sum=%d",sum);
getch();
}
Output:
Enter the beginning and end range of number:
10
15
sum=36
No comments: