Thursday, August 27, 2009

Sum of Series (1^3+3^3+5^3+.....+n^3)

1^3+3^3+5^3+.....+n^3
#include
#include
#include
void main()
{
int i,n,s=0;
clrscr();
printf("Enter Value 'n' to Find Series 1^3+3^3+5^3+...+n^3 : ");
scanf("%d",&n);
for(i=1;i<=n;i+=2)
s=s+pow(i,3);
printf("\n\tSum of Series is %d",s);
getch();
}

Output
Enter Value 'n' to Find Series 1^3+3^3+5^3+...+n^3 : 5
Sum of Series is 153

No comments:

Post a Comment