Make a new start with a new Thought!

NOTE :                // indicates comments.This wont get printed in the output.This is used for for documentation purpose. PROGRAM: #incl...

Binary To Octal Conversion

NOTE :
              
// indicates comments.This wont get printed in the output.This is used for for documentation purpose.

PROGRAM:

#include<stdio.h>
#include<conio.h>
void main()
{
  long int octal=0,binary,rem,i=1;
  clrscr();
  printf("Enter any Binary number\t:\t");
  scanf("%ld",&binary);
  while(binary!=0)
  {
     rem=binary%10;
     octal=octal+rem*i;
     i=i*2;
     binary=binary/10;
  }
  printf("\nThe Quivalent value in octal number is\t:\t%\o",octal);
  getch();
}

OUTPUT :

0 comments: