Saturday, 9 February 2013

hexamial to binary conversion in c++

#include<iostream.h>
#include<conio.h>

class conversion
{
private:
   int n,i,j;
   int arr[24],a[24];
public:
void input()
{
cout<<"enter no of hexa numbers you want to enter:        ";
cin>>n;
for (i=0;i<n;i++)
{cout<<"enter hexa no:      ";
cin>>arr[i]; }
}

void output()
{

for(i=0;i<n;i++)
    {
    for(j=0;j<4;j++)
        {
        a[j]=arr[i]%2;
        arr[i]=arr[i]/2;
        }
   for(j=3;j>=0;j--)
   cout<<a[j]<<"\t";
    }

}
};

void main()
{
conversion c;
c.input();
c.output();

getch();
}

0 comments:

Post a Comment