C program to convert decimal number to octal number.

Posted by Mangesh on April 25, 2018

/* program to convert decimal number into octal number. */

Description :

Decimal number are those number with 10 symbols and octal number are those with eight symbols use to represent number.

Program :

#include<stdio.h>
#include<conio.h>
void main()
{
 int num,rem,oct=0,base=1;
 printf("Enter the number : ");
 scanf("%d",&num);
 while(num>0)
 {
  rem = num % 8;
  oct = oct + rem * base;
  num = num / 8;
  base = base * 10;
 }
 printf("Octal value is %d",oct);
 getch();
}


Output :

c program for dec to oct Executed and tested in Turbo C 3.2

Written with from Mangesh.

Related Post
1 C program to check whether given number is prime number or not.
2 C program for Fibonacci Series upto a limited ranges.
3 C program to find whether the number is Armstrong number or not.
4 C program to convert decimal number to octal number.
Latest Post
1 shubhanshu
2 test
3 C program for Breadth First Search.
4 C program for Depth First Search(DFS).
5 C for circular queue using linked list.