SA Activities
a CSE.B-Tech Student's Blog
Saturday, 27 July 2013
C-Program To Find The SUM Of ODD Numbers Upto a Limit
#include<stdio.h>
main ()
{
int sum=0,n,i;
printf("Enter the Limit\t");
scanf("%d",&n);
for(i=1;i<=n;i=i+2)
{
if(i%2!=0)
{
sum=sum+i;
}
}
printf("Sum of Odd Numbers Upto %d is %d",n,sum);
}
output
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment