Please click on 1-2 Ads to keep this website's Study Material FREE and regularly Updated.

Program 54: Write a C++ program to find the sum of the series (9 + 99 + 999 + _ _ _ _ ).

#include<iostream>
using namespace std;

int main()
{
	int n=9,num=0,sum=0;
	cout<<"\nenter the number of terms : ";
	cin>>num;

	for(int i=1;i<=num;i++)
	{
		sum+=n;
		n=n*10+9;
	}
	cout<<"\nsum of the 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.