#include<stdio.h>
int main ()
{
int n,i,sumeven=0,sumodd=0;
printf("ENTER THE LIMIT\n");
scanf("%d",&n);
for (i=1;i<=n;i++)
{
if ((i%2)==0)
{sumeven=sumeven+i;}
else
{sumodd=sumodd+i;}
}
printf("\n\nSUM OF EVEN NUMBERS UPTO %d is %d\n",n,sumeven);
printf("\n\nSUM OF ODD NUMBERS UPTO %d is %d\n",n,sumodd);
return 0;
}
Have a Read!
Hi Everyone.
The idea for this page is to provide new c users simple c tutorials to learn how to develop the logic and more importantly correct way to write syntax.
ENJOY !!!
Thursday, January 27, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment