Program to display series and find sum of 1+3+5+…+n in C language

The series 1+3+5+..+n, is a series of odd number. We need to write a program to display this series as well as find the sum upto nth number. The n will be inserted by the user. The program has been compiled and executed under DEV c++.


void main()
	int i,n,sum=1;
	printf("Enter any number n:");
	printf("\n1 ");
		printf("+ %d ",i);
	printf("\nSum is: %d", sum);


Series in c in odd number

Explanation: The i is incremented twice in the above program. First in the for loop itself and second inside the loop. There are multiple ways to do this. I choose to do it this way.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: