Bismillahir Rahmanir Rahim
The addition and average of three numbers input from the keyboard by using Nesting member function and private function in C++ .
Solution:
if you have to face any problem to solve or understand it ,comment below or contact admain in facebook .
Solution:
#include<iostream.h> class sum_average { int a,b,c,sum; float avg; void input();//privat function call public: void print_line(char ch); int add(); float average(); void show(); }; void sum_average::print_line(char ch) { for(int i=0;i<=40;i++) { cout<<ch; } cout<<endl; } void sum_average::input() { cout<<"Enter your numbers:"<<endl<<"a="; cin>>a; cout<<"b="; cin>>b; cout<<"c="; cin>>c; } int sum_average::add() { input(); sum=a+b+c; return sum; } float sum_average::average() { avg=sum/3; return avg; } void sum_average::show() { cout<<"The sum of two numbers is= "<<sum<<endl; cout<<"The average of two numbers is = "<<avg<<endl; print_line('*'); } void main() { char n; main: sum_average obj; obj.print_line('*'); obj.add(); obj.average(); obj.show(); cout<<"If you want to run again press a/A"<<endl; cin>>n; if(n=='a' ||n=='A') goto main; else cout<<"Thank you"<<endl; obj.print_line('#'); }
if you have to face any problem to solve or understand it ,comment below or contact admain in facebook .