Write a program to find the number and sum of all integer between 100 and 200 which are divisible by 9 using the classes.
//Write a program to find the number and sum of all integer between 100 and 200 which are divisible by 9.
#include<iostream>
using namespace std;
class number
{
private:
int i,sum=0;
public:
int show_num()
{
for(i=101; i<200; i++)
if(i%9==0)
{
cout<<"numbers divisble by 9 is= "<<i<<endl;
sum=sum+i;
}
cout<<"sum of all numbers divisible by 9 is= "<<sum<<endl;
}
};
int main()
{
number f;
f.show_num();
}
WAP to find the number and sum of all integer between 100 and 200 which are divisible by 9 using the single inheritance.
//Write a program to find the number and sum of all integer between 100 and 200 which are divisible by 9.
//single inheritence
#include<iostream>
using namespace std;
class number
{
protected:
int i,sum=0;
};
class child:public number
{
public:
int show_num()
{
for(i=101; i<200; i++)
if(i%9==0)
{
cout<<"numbers divisble by 9 is= "<<i<<endl;
sum=sum+i;
}
cout<<"sum of all numbers divisible by 9 is= "<<sum<<endl;
}
};
int main()
{
child f;
f.show_num();
}
WAP to show the sum of all integer between 100 and 200 which are divisible by 9 with the help of multiple inheritances.
//Write a program to find the number and sum of all integer between 100 and 200 which are divisible by 9.
//multiple inheritence
#include<iostream>
using namespace std;
class number
{
protected:
int i;
};
class number2
{
protected:
int sum=0;
};
class child:public number,public number2
{
public:
int show_num()
{
for(i=101; i<200; i++)
if(i%9==0)
{
cout<<"numbers divisble by 9 is= "<<i<<endl;
sum=sum+i;
}
cout<<"sum of all numbers divisible by 9 is= "<<sum<<endl;
}
};
int main()
{
child f;
f.show_num();
}
WAP to show the sum of all integer between 100 and 200 which are divisible by 9 with the help of multi-level inheritance.
//Write a program to find the number and sum of all integer between 100 and 200 which are divisible by 9.
//multi level inheritence
#include<iostream>
using namespace std;
class number
{
protected:
int i;
};
class number2:public number
{
protected:
int sum=0;
};
class child:public number2
{
public:
int show_num()
{
for(i=101; i<200; i++)
if(i%9==0)
{
cout<<"numbers divisble by 9 is= "<<i<<endl;
sum=sum+i;
}
cout<<"sum of all numbers divisible by 9 is= "<<sum<<endl;
}
};
int main()
{
child f;
f.show_num();
}