Simple C program to convert decimal to octal number.

 CODE:-

#include <stdio.h>

int main()

{

    int num,oct,rem;

    int total=0;

    int octal=0;

    printf("please enter the number that you want to convert into octal number:- ");

    scanf("%d",&num);

    int deci=num;

    do

    {

       rem=num%8;

       num=num/8;

       total=total*10+rem;

       

    }

    while(rem>0);

    total=total/10;

    printf("Total=%d\n",total);

    do

    {

        rem=total%10;

        total=total/10;

        octal=octal*10+rem;

    }

    while(rem>0);

    octal=octal/10;

    printf("octal of %d is %d",deci,octal);

    


    return 0;

}


Comments

Popular posts from this blog

Tips to improve Coding Skill