Write a program to find out the sum of the series
1 + x + x2 + x2 ................ xn
PROGRAM:
#include <iostream.h>
#include <conio.h>
#include <math.h>
void main() {
clrscr();
int term,num;
long int sum=1;
cout<<"Enter the number to take the series of: ";
cin>>num;
cout<<"Enter the term for which the series is to be taken: ";
cin>>term;
for(int i=2;i<=term;i++) {
sum+=pow(num,i);
}
cout<<"The sum of the series: "<<sum;
getch();
}//end of the program
Monday, May 5, 2008
program to find sum of the series in c++
Labels:
definite loop,
for loop,
iteration,
sum of series
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment