Pages

Friday, 4 August 2017

Sum of series

#include<stdio.h>
void main()
{
     int i,j,k=0;
     char sym='+';
     printf("Enter n>> ");
     scanf("%d",&i);

     for(j=1;j<i;j+=2)
     {
          sym=sym=='+'?'-':'+';
          k+=j;
          printf("%d %c ",j,sym);
     }
}



No comments:

Post a Comment