/*******************************************************
Program to convert a decimal number to an octal number
******************************************************/
#include<stdio.h> // include stdio.h library
#include<math.h> // include math.h library
int main(void)
{
long long num, oct = 0;
int i = 0, rem;
printf("Enter a decimal number: \n");
scanf("%lld", &num);
while(num != 0)
{
rem = num % 8; // get the last digit
oct = rem * (long long)pow(10, i++) + oct;
num /= 8; // get the quotient
}
printf("0o");
printf("%lld", oct);
return 0; // return 0 to operating system
}