Computer Science, asked by Samsulislam, 7 months ago

Write a C++ function that converts a 2-digit octal number into binary number & prints the binary equivalent.​

Answers

Answered by Hannnnnnna
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