Answer to Question #250767 in C++ for QAMAR

Question #250767

Write a program to calculate and display sum of the following series using for loop x+x2+x3+………xn


1
Expert's answer
2021-10-13T07:30:55-0400
#include <iostream> 
#include <cmath> 


using namespace std; 


int main(){ 
	int n,x;
	int sum=0;
	cout<<"Enter n: ";
	cin>>n;
	cout<<"Enter x: ";
	cin>>x;


	for(int i=1;i<=n;i++){
		sum+=pow(x*1.0,i);
	}


	cout<<"Sum = "<<sum<<"\n";


	cin>>n;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS