Answer to Question #264987 in C for Jack

Question #264987

Octal number system has been popularly used as a potential number system in computing texts,


graphics, and especially file protection systems in UNIX operating system. Develop a C- script that


takes a decimal number as an input and produces its equivalent octal number.


[DoB]10 = (----)8


DoB: Date of birth


Note : Don't use array, do with loops

1
Expert's answer
2021-11-12T07:16:45-0500
void ConvertDecToOctal(int num)
{
    int j,k=0, OctNum[100];
    while (num != 0) 
	{
        OctNum[k] = num % 8;
        num = num / 8;
        k++;
    }
    printf("\n\tEquivalent Octal Number = ");
    for (j = k - 1; j >= 0; j--) printf("%d ",OctNum[j]);
}
 
int main()
{
    int n = 123;
    printf("\n\tDecimal Number = %d",n);
    ConvertDecToOctal(n);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS