#include<iostream.h>
#include<conio.h>
class conversion
{
private:
int n,i,p,q;
int arr[23],ar[23],a[23];
public:
void input()
{
cout<<"how many hexa nos you want to enter? ";
cin>>n;
cout<<endl<<endl;
p=0;
n--;
cout<<"enter '10' for 'A'"<<endl;
cout<<"enter '11' for 'B'"<<endl;
cout<<"enter '12' for 'C'"<<endl;
cout<<"enter '13' for 'D'"<<endl;
cout<<"enter '14' for 'E'"<<endl;
cout<<"enter '15' for 'F'"<<endl;
cout<<"\n\n";
for(i=n;i>=0;i--)
{cout<<"enter hexa no ";
cin>>arr[i];
p++;}
}
void func()
{
n=1;
i=0;
do
{
ar[i]=n;
n=n*16;
i++;
}
while(n<=65536);
}
void output()
{ p--;
for(int j=0;j<=p;j++)
{
a[j]=arr[j]*ar[j];
}
q=0;
for(int j=0;j<=p;j++)
q=q+a[j];
cout<<endl<<endl;
cout<<"decimal conversion "<<q;
}
};
void main()
{
conversion c;
c.input();
c.func();
c.output();
getch();
}
#include<conio.h>
class conversion
{
private:
int n,i,p,q;
int arr[23],ar[23],a[23];
public:
void input()
{
cout<<"how many hexa nos you want to enter? ";
cin>>n;
cout<<endl<<endl;
p=0;
n--;
cout<<"enter '10' for 'A'"<<endl;
cout<<"enter '11' for 'B'"<<endl;
cout<<"enter '12' for 'C'"<<endl;
cout<<"enter '13' for 'D'"<<endl;
cout<<"enter '14' for 'E'"<<endl;
cout<<"enter '15' for 'F'"<<endl;
cout<<"\n\n";
for(i=n;i>=0;i--)
{cout<<"enter hexa no ";
cin>>arr[i];
p++;}
}
void func()
{
n=1;
i=0;
do
{
ar[i]=n;
n=n*16;
i++;
}
while(n<=65536);
}
void output()
{ p--;
for(int j=0;j<=p;j++)
{
a[j]=arr[j]*ar[j];
}
q=0;
for(int j=0;j<=p;j++)
q=q+a[j];
cout<<endl<<endl;
cout<<"decimal conversion "<<q;
}
};
void main()
{
conversion c;
c.input();
c.func();
c.output();
getch();
}
0 comments:
Post a Comment