TheFestFever.com

Our aim is to connect students from campuses all over Delhi by making them aware of all Technical, Cultural, Management fests, workshops, Seminars organized by every college in Delhi.

Join Us Now

Program 26: Write a C++ program to print and find the sum of gp series.

#include<iostream>
#include<math.h>
using namespace std;

int main()
{
	int num,cd,g1,sum=0;
	cout<<"\nenter the first term of gp series : ";
	cin>>g1;
	cout<<"\nenter the common ratio between terms : ";
	cin>>cd;
	cout<<"\nenter the number of terms : ";
	cin>>num;
	cout<<"\nGP series : \n"<<g1;
	sum=g1;

	for(int i=1;i<num;i++)
	{
		int gp_term=g1*pow(cd,i);
		cout<<"\t"<<gp_term;
		sum+=gp_term;
	}
	cout<<"\nsum of given gp series : "<<sum;
	return 0;
}


If you have any suggestion or found any error in the above program, then do let us know at [email protected] or just comment below.