Wap to find octal conversion of a given deimal number

/*WAP to find octal conversion
of a given deimal number*/

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

void main()

{
 long int n,a,b=0,i=0,k,j,s[16];
 clrscr();

 printf("Enter any Decimal Number:");
 scanf("%ld",&n);
 printf("Octal\n");
  while(n!=0)
  {
   a=n%8;
   n=n/8;
   b=b+a*pow(10,i);
   i++;
  }
  printf("\nOctal Conversion:%ld",b);
 
 getch();
}

No comments:

Post a Comment