#include #include //This time we have to return the octal value from function (instead of using // global variables. Note that only one number (an integer) can be returned. // We can return the whole octal value by formatting it. // // for example: 453 is 705 in octal; r2 is 7, r1 is 0, and r0 is 5 // remember that 7*100 = 700; adding this to 0*10 gives 700; adding to 0 = 705 // The octal result in one number! int octalValue(int n) { int r0, r1 ,r2; int q0, q1, q2; q0 = n/8; r0 = n%8; q1 = q0/8; r1 = q0%8; q2 = q1/8; r2 = q1%8; return r2*100 + r1*10+r0; } int main() { int n; printf("enter a number: "); scanf("%d", &n); //we can call the function by using it as an argument in the printf function printf("%d in octal is: %d\n", n, octalValue(n)); system("pause"); }