C++ Program to display the sum of the series using Multiple inheritance
Write a program in C++ to display the sum of the series using multiple 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 T4Tutorials { public: long int num,i; }; class T4Tutorials2 { public: int sum=0,k=9; }; class child:public T4Tutorials,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() { child obj; obj.function(); } |
Output
Please input the number of terms. 6
the sum of the series is 1111104.
Write a program to find the sum of the following series using multiple inheritances.
Different series programs in c++ using the multiple inheritances.
All series program in C++ using the multiple inheritances.