Write a C++ function that converts a 2-digit octal number into binary number & prints the binary equivalent.
Answers
Answered by
1
Answer:
hope this is useful
Explanation:
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
int n,i=0,j=0,bin[10],dec=0;
cout <<"Enter two digit octal no: "<<endl;
cin>>n;
while(n)
{
dec=dec + (n%10)*pow(8,i);
n=n/10;
i++;
}
//cout <<dec<<endl;//decimal of diven octal
while(dec)
{
bin[j]=dec%2;
dec=dec/2;
j++;
}
for(i=j-1;i>=0;i--)
cout<<bin[i];
return 0;
}
Similar questions
India Languages,
3 months ago
Computer Science,
3 months ago
Math,
3 months ago
English,
7 months ago
History,
7 months ago
English,
1 year ago
Geography,
1 year ago