1.

Write a program to find sum of the seriesS = 1 + x + x2 + …….. + xn

Answer»

# include

using namespace std;

# include int main()

{

int x, n;

float sum = 0;

cout <<“Enter the value for x:”; cin>>x;

cout <<“Enter the number of terms”; cin>>n;

for (int i = 0; i<=n; i++)

sum = Sum + Pow(x,i);

cout << “Sum= ” << Sum << endl;

cin.get( );

return 0;

}



Discussion

No Comment Found