Convert Binary Number to Octal

Write a C program to convert a binary number to its corresponding octal number.

Questions by seoraju

Showing Answers 1 - 1 of 1 Answers

#include<stdio.h>
#include<conio.h>


main()
{
    int i=12;
    void printoctal(int,int);
    printoctal(i,i);
    getch();
}

void printoctal(int val,int rem)
{
    if(rem == 0)
      return;
    rem = val%8;
    val = val/8;
    printoctal(val,rem);
    if(rem != 0)
    printf("%d",rem);
}

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions