C++ Program to display the sum of the series using Multilevel inheritance
Write a program in C++ to display the sum of the series using multilevel inheritances.
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 | #include <iostream> using namespace std; class T4Tutorials1 { public: long int num,i; }; class T4Tutorials2:public T4Tutorials1 { public: int sum=0,k=9; }; class series3:public T4Tutorials2 { public: int function() { cout<<"input the number of terms"; cin>> num; for(i=1;i<=num;i++) { sum=sum+k; k=k*10+9; } cout<<"sum of series"<<sum; } }; int main() { series3 obj; obj.function(); } |
Output
Please input the number of terms. 7
the sum of the series is 11111103.
Write a program to find the sum of the following series using Multi-level inheritance.
Different series programs in c++ using the Multi-level inheritance.
All series program in C++ using the Multi-level inheritance.