#include<stdio.h>
#include<math.h>
main()
{
int oct_num,oct,dec_num,dec,remainder,i,n;
printf("***************Welcome to Converter***************"); printf("\n\n\n1.Octal to Decimal\n\n2.Decimal to Octal\n\n Enter Your choice : "); switch(n)
{
case 1:
printf("\nPlease, Enter the Octal number : "); oct=oct_num;
i=0;
dec=0;
while(oct_num!=0)
{
remainder=oct_num%10;
dec
=dec
+remainder
*pow(8,i
);i++;
oct_num=oct_num/10;
}
printf("\nThe decimal of %d is : %d",oct
,dec
); break;
case 2:
printf("\nPlease, Enter the Decimal number : "); dec=dec_num;
i=1;
oct=0;
while(dec_num!=0)
{
remainder=dec_num%8;
dec_num=dec_num/8;
oct=oct+remainder*i;
i=i*10;
}
printf("\nThe octal of %d is : %d",dec
,oct
); break;
default:
printf("\n SORRY !!! You have Entered a wrong choice."); break;
}
return 0;
}