#include <iostream>
#include <iomanip>
void binary_converter (int);
using namespace std;
int main()
{
float Num;
cout<<"Number: ";
cin>>Num;
cout<<"Binary: "; binary_converter(Num);
cout<<endl;
return 0;
}
void binary_converter (int Num)
{
int a, i = 20;
while (Num != 0)
{
a = Num % 2;
Num=Num/2;
cout<<"\r"<<setw(i--)<<a;
}
}
#include <iomanip>
void binary_converter (int);
using namespace std;
int main()
{
float Num;
cout<<"Number: ";
cin>>Num;
cout<<"Binary: "; binary_converter(Num);
cout<<endl;
return 0;
}
void binary_converter (int Num)
{
int a, i = 20;
while (Num != 0)
{
a = Num % 2;
Num=Num/2;
cout<<"\r"<<setw(i--)<<a;
}
}
You may want to see: Generic Binary to Decimal Converter
No comments:
Post a Comment