Write a program to display sum of even numbers from 1-10

//this is a program to display sum of even numbers from 1-10
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1,sum=0;

printf("\n\nPrinting Sum of all the Odd numbers from 1-10");

    while(i<=10)
{
if(i%2!=0)
{
sum=sum+i;
}
i++;
}

printf("\n\nSum=%d",sum);

getch();
}


Previous
Next Post »