Write a program in C++ to find the sum of the series using inline function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #include<iostream> using namespace std; class T4Tutorials { private: int n; int s=0; public : int even(); }; inline T4Tutorials::even() { cout<<"enter the value : To print Even Number"<<endl; 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; } int main() { T4Tutorials u; u.even(); } |