Monday, May 7, 2018

WACP to print the value of a series S=1+X+X3+X5 +…. +nth term.




#include<stdio.h>
#include<math.h>
#include<conio.h>
int main()
{
int n,i,j=1,sum=1;
printf("Enter The Last Number : ");
scanf("%d",&n);

for(i=0;i<n;i++)
{
sum=sum+pow(n,j);
j=j+2;
}
printf("Sum = %d",sum);

        getch();

        return 0;
}




OUTPUT : 

Enter The Last Number : 3
Sum = 274


NB: (1+3^1+3^3+3^5)=274

0 comments: