#include<iostream.h>
#include<conio.h>
class converter
{
private:
int n,i;
int b,in;
int arr[23];
public:
void input()
{
cout<<"enter decimal no: ";
cin>>n;
}
void func()
{
i=0;
in=0;
do
{
arr[i]=n%16;
n=n/16;
i++;
in++;
}
while(n>=1);
}
void output()
{
in--;
cout<<"Hexa conversion is: ";
for(i=in;i>=0;i--)
switch(arr[i])
{case 10:
cout<<"A"<<"\t";
break;
case 11:
cout<<"B"<<"\t";
break;
case 12:
cout<<"C"<<"\t";
break;
case 13:
cout<<"D"<<"\t";
break;
case 14:
cout<<"E"<<"\t";
break;
case 15:
cout<<"F"<<"\t";
break;
default:
cout<<arr[i]<<"\t";
}
}
};
void main()
{
converter c;
c.input();
c.func();
c.output();
getch();
}
#include<conio.h>
class converter
{
private:
int n,i;
int b,in;
int arr[23];
public:
void input()
{
cout<<"enter decimal no: ";
cin>>n;
}
void func()
{
i=0;
in=0;
do
{
arr[i]=n%16;
n=n/16;
i++;
in++;
}
while(n>=1);
}
void output()
{
in--;
cout<<"Hexa conversion is: ";
for(i=in;i>=0;i--)
switch(arr[i])
{case 10:
cout<<"A"<<"\t";
break;
case 11:
cout<<"B"<<"\t";
break;
case 12:
cout<<"C"<<"\t";
break;
case 13:
cout<<"D"<<"\t";
break;
case 14:
cout<<"E"<<"\t";
break;
case 15:
cout<<"F"<<"\t";
break;
default:
cout<<arr[i]<<"\t";
}
}
};
void main()
{
converter c;
c.input();
c.func();
c.output();
getch();
}
0 comments:
Post a Comment