Write a C++ program of binary to octal conversion with friend function.
/* binary to octal conversion with friend function*/
#include<iostream>
using namespace std;
class T4Tutorials
{
protected :
int i,j;
int dn,T4Tutorials_Octal,temp;
public :
Process()
{
cout<<".....Program for decimal to octal "<<endl;
cout<<"using the friend function..."<<endl;
cout<<"Input The Number to convert into Octal : "<<endl;
cin>>dn;
temp=dn;
i=1;
for(j=dn ; j>0 ; j=j/8)
{
T4Tutorials_Octal=T4Tutorials_Octal+(j%8)*i;
i=i*10;
}
}
friend int show(T4Tutorials);
};
int show(T4Tutorials a)
{
cout<<"Your Input Decimal is :"<<a.temp;
cout<<"Octal Value After conversion is : "<<a.T4Tutorials_Octal<<endl;
}
int main()
{
T4Tutorials a;
a.Process();
show(a);
}
