How to convert binary number to 8 bits
Hye..good day everyone..i need some help here..i have converted decimal number to binary number..but i have a problem..could someone help me on how to make the binary number to 8 bits only...
thank u for ur help~!!
Code:
#include <conio.h>
#include <iostream>
using namespace std;
void convertBinary( int n ) {
if( n<2 ) {
cout<<"binary is--> "<<n;
return;
}
convertBinary(n/2);
cout<<n % 2;
}
int main(){
int n;
int x;
cout<<"n:";
cin>>n;
convertBinary( n );
getch();
return 0;
}