Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to convert decimal to octal

Posted By: Binge Fischer     Category: C Programming     Views: 23004

Write a program to convert decimal to octal.

Code for Program to convert decimal to octal in C Programming

#include<stdio.h>
#include<conio.h>
int i=0,bin[100];
void main()
{
    int j=0;
    int read(),destobin();
    clrscr();
    j=read();
    destobin(j);
    getch();
}

int read()
{
    int num;
    printf("\n PLEASE ENTER THE VALUE IN DECIMAL ( 0 - 7 ): ");
    scanf("%d",&num);
    return(num);
}

int destobin(int j)
{
    for(i=0;j>0;i++)
    {
        bin[i]=j%8;
        j=j/8;
    }
    i--;
    printf("\nDECIMAL TO OCTAL CONVERSION IS ");
    for(i;i>=j;i--)
        printf("%d",bin[i]);
}
  
Share: 


Didn't find what you were looking for? Find more on Program to convert decimal to octal Or get search suggestion and latest updates.

Binge Fischer
Binge Fischer author of Program to convert decimal to octal is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!