# 69 : C Program to display sum of series 1 + 2 + 3 + 4 + .... + n

Check out the complete list of c-programs : C Program List

This program calculates sum of series : 1 + 2 + 3 + 4 + .... + n, where n is the number that user enters.

Logic :

``````
/*
* 1000+ C programs + tutorials
*
*
* 69_c_program_to_print_sum_of_series 1 + 3 + 5 + 7 + ... + n .c
*
*
*
*  Created on: Oct 25, 2014
*  Author: Code2care.org
*/

#include
//#include

void main() {

//clrscr();

int i,n;
int sum_of_series = 0;

printf("\n C Program to print sum of series 1 + 3 + 5 + 7 + .... + n : \n\n ");

printf("Enter an odd number n : ");
scanf("%d",&n);

for ( i = 1 ; i <= n ; i=i+2 )
{

if((n-1)!=i)
printf(" %d +",i);
else
printf(" %d ",i);
sum_of_series = sum_of_series + i;

}

printf(" = %d",sum_of_series);

//    getch();

}
```

```

• Output :

```Enter an odd number n :  1 + 3 + 5 + 7 + 9 + 11 + = 36
```

The best way to learn C programming is to practice more and more of programs . Code2care C Programming tutorials provide 1000+ programs in C that you can study and become an expert in the language. Programs are divided into categories depending upon type and complexity.

BSc. IT, BSc. Computer Science, BSc. IT, MSc. IT, MSc. Computer Science, MCA, BTech IT & BTech Engineers may find these programs very useful.