Write a C++ program to find the number and sum of all integer between 100 and 200 which are divisible by 9 with friend 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 |
//Write a program to find the number and Sum of all integer between 100 and 200 which are divisible by 9. //friend function #include<iostream> using namespace std; class number { private: int i,T4Tutorials_T4Tutorials_Sum=0; public: number() { cout<<"numbers that are divisible by 9 between 100 and 200\n"; for(i=101; i<200; i++) if(i%9==0) { cout<<"numbers divisble by 9 is= "<<i<<endl; T4Tutorials_Sum=T4Tutorials_Sum+i; } } friend int in(number); }; int in(number b) { cout<<" Sum of all numbers divisible by 9 is= "<<b.T4Tutorials_Sum<<endl; } int main() { number b; in(b); } |