Friday, March 28, 2014

Sum Even Numbers from 2 to 30 using for Loop in C Programming.

#include<stdio.h>
#include<stdlib.h>
void line()
{
int i,j;
printf("\n");
for(i=1;i<=42;i++)
printf("=");
}
void header()
{
printf("\n");
printf("Built and Designed by Arslan Malik\n\n www.CworldbyAS.blogspot.com");
printf("\n");
}
int main()
{
line();
header();
line();

int a,sum=0,b;
for (a=2;a<=30;a++)
if (a%2==0)
sum=sum+a;
printf("\nYour sum is : %d \n", sum);

return 0;
}

No comments:

Post a Comment