#include<stdio.h>
#include<conio.h>
main()
{
  int p=1,num=0,oct=0,d;
  clrscr();
  printf("\n enter the decimal number=");
  scanf("\n %d",&num);
  while(num)
  {
 d=num%8;
 oct=oct+p*d;
 p=p*10;
 num=num/8;
   }
      printf("\n octal number %d",oct);
  getch();
}
output:-enter the decimal number=8
octal number=10
 
No comments:
Post a Comment