program in C++ to find the sum of the series 1 +11 + 111 + 1111 + .. n terms. .

#include <iostream>
using namespace std;
void main()
{
int n,i,sum=0;
  long int t=1;
  cout<<"Input the number of terms : ";
  cin>>n;
  for(i=1;i<=n;i++)
  {
     printf("%ld + ",t);
     sum=sum+t;
     t=(t*10)+1;
  }
  cout<<"\nThe Sum is : "<<sum<<endl;

system ("pause");
}

program in C++ to find the sum of the series 1 +11 + 111 + 1111 + .. n terms. . program in C++ to find the sum of the series 1 +11 + 111 + 1111 + .. n terms. . Reviewed by Unknown on May 21, 2017 Rating: 5

No comments:

Powered by Blogger.