Sunday 15 December 2013

C program to Convert Decimal to Octal

#include < stdio.h>
 
int main()
{
    long decimalnum, remainder, quotient;
    int octalNumber[100], i = 1, j;
 
    printf("Enter the decimal number: ");
    scanf("%ld", &decimalnum);
    quotient = decimalnum;
    while (quotient != 0)
    {
        octalNumber[i++] = quotient % 8;
        quotient = quotient / 8;
    }
    printf("Equivalent octal value of decimal no %d: ", decimalnum);
    for (j = i - 1; j > 0; j--)
        printf("%d", octalNumber[j]);
    return 0;
}

Output

 Enter the decimal number:  68 
Equivalent octal value of decimal no  68 :  104 

For More Details Please Visit Ictjobs.info

No comments: