Write a program in C++ to find the sum of the series using friend function.
#include<iostream>
using namespace std;
class T4TUTORIALS
{
protected :
int i,j;
int s=0;
public :
read()
{
cout<<"enter the value";
int n;
cin>>n;
int s=0;
int t=1,i=1;
for(i=1;i<=n;i++)
{
cout<<" "<<t<<" ";
if (i<n)
{
cout<<"+";
}
s=s+t;
t=(t*10)+1;
}
cout<<endl<<"The Sum is :"<<s;
}
friend int show(T4TUTORIALS);
};
int show(T4TUTORIALS a)
{
cout<<"sum of given input = "<<a.s;
}
int main()
{
T4TUTORIALS a;
a.read();
show(a);
}
