Advertisement

Find the summation of odd numbers


#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,s;
clrscr();
printf("Input values::");
scanf("%d",&n);
s=0;
for (i=1;i<=n;i++)
if(i%2!=0)
s=s+i;
printf("Result=%d",s);
getch();
}

No comments:

Post a Comment

Please comment bellow. Share your knowledge