#include <stdio.h>
//typedef to avoid long name
typedef unsigned long long ULLINT;
// Function to return the octal
// equivalent of decimal value num
ULLINT decimalToOctal(ULLINT num)
{
// To store the octal number
ULLINT binNum = 0;
int cnt = 0;
while (num != 0)
{
int rem = num % 8;
ULLINT c = pow(10, cnt);
binNum += rem * c;
num /= 8;
// Count used to store exponent value
cnt++;
}
return binNum;
}
int main()
{
//num for decimal number
ULLINT num;
printf("Enter decimal number: ");
scanf("%lld", &num);
//Called function
printf("%lld",decimalToOctal(num));
return 0;
}
Output:
Enter a decimal number: 74
need an explanation for this answer? contact us directly to get an explanation for this answer112