In this tutorial, we are going to write a C Program to display odd Number series and find the sum of 1+3+5+...+n in C Programming with practical program code and step-by-step full complete explanation.

C Program to display odd Number series and find the sum of 1+3+5+...+n


C Program to display odd Number series.

 
#include<stdio.h>
#include<conio.h>

void main()
{
	int n,i,sum=0;

	clrscr();

	printf("Enter any number: ");
	scanf("%d",&n);
	for(i=1;i<n;i+2)
	{
		printf("%d+",i);
		sum = sum+i;
	}
	printf("\nsum=%d",sum+n);
	getch();
}


Output

 
Enter any number: 7
1+3+5+7
Sum=16