#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%2;
n=n/2;
i++;
in++;
}
while(n>=1);
}
void output()
{
in--;
cout<<"binary conversion is: ";
for(i=in;i>=0;i--)
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%2;
n=n/2;
i++;
in++;
}
while(n>=1);
}
void output()
{
in--;
cout<<"binary conversion is: ";
for(i=in;i>=0;i--)
cout<<arr[i]<<"\t";
}
};
void main()
{
converter c;
c.input();
c.func();
c.output();
getch();
}
0 comments:
Post a Comment