#include "string.h"
#include "iostream.h"
void binary(int x, int y){
if(y!=0){
int bin=x/y;
cout<<bin;
binary(x%y,y/2);
}
}
int main(){
int n[100];
char octal[100];
cout<<"enter the octal number : ";
cin>>octal;
int length=strlen(octal);
int cek=1;
for(int i=0;i<length;i++){
n[i]=octal[i]-48;
if(n[i]>7 || n[i]<0){
cek=0;
break;
}
}
if(cek==0){
cout<<"nilai yang anda masukan bukan bilangan octal"<<endl;
}else{
for(int i=0;i<length;i++){
binary(n[i],4);
}
}
}
0 komentar:
Posting Komentar