-->
Showing posts with label program to get sum of series 1. Show all posts
Showing posts with label program to get sum of series 1. Show all posts

program to get sum of series 1 ,3,5,7,.......nth.

//program  to get sum of series 1 ,3,5,7,.......nth.
#include<stdio.h>
#include<conio.h>
void main()
{
int k,n;
int s=0;printf(enter value of 'n'\n");
scanf("%d",&n);
for(k=1;k<=n;k=k+2)
   {          
       s=s+k;
   }
printf("sum=%d,",s);
getch();
}