C Program to Convert Decimal number into Octal Number

This page has a C Program to Convert Decimal number to Octal Number. It is clear that, this C program will Convert the given Decimal number into Octal Number. To convert decimal number into Octal number, the program should divide the decimal number by 8 again and again till the number can be divided by 8 and the program should display (print) the remainders for each division on monitor screen (in reverse order) to form the Octal equivalent. For Example: If the Decimal number 39 is given as input, the program will print the Octal equivalent as 47 The below given C program is used to Convert the given Decimal number into Octal Number. Kindly check out the program to Convert the given Decimal number into Octal Number.

How will ask to Convert Decimal number to Octal Number

The Questions to Convert Decimal number intoOctal Number problem can be asked as . . 1). C Program to Convert Decimal number to Octal Number. 2). C Program to Convert the given Decimal number into Octal Number. 3). C Program to find the Octal equivalent of given Decimal number. 4). C Program to Print Octal Equivalent of a Decimal Integer. 5). Program to convert decimal to Octal in c. 6). C Program to Convert the given Decimal value into Octal value. 7). C Program to display the Octal Number for the given decimal number.

Decimal number to Octal Number Program

#include<stdio.h>

#include<conio.h>

void decimal_to_octal(long int);

int main(){

long int decimal;

clrscr();

printf("Enter an Integer decimal number : ");

scanf("%ld", &decimal);

printf("



The given decimal number is : %ld", decimal);

decimal_to_octal(decimal);

getch();

return(0);

}

void decimal_to_octal(long int n){

long int a=1, i, remain[40];

printf("



The Octal number is : ");

while(n>0){

remain[a] = n % 8;

n = n / 8;

a++;

}

a--;

for(i=a;i>=1;i--)

printf("%ld", remain[i]);

}

Sample Output: Enter an Integer decimal number : 43



The given decimal number is : 43

The Octal number is : 53

