# Decimal to octal program

#### decimal to octal in c

``` #include<stdio.h> #include<conio.h> void main() { int octalNumber[100]; int decimalNumber,count=0; printf("Enter the decimal number \n"); scanf("%d",&decimalNumber); for(int i=0;decimalNumber>0;i++) { octalNumber[i]=decimalNumber%8; decimalNumber/=8; count++; } printf("Its equivalent octal number is = "); for(int j=count-1;j>=0;j--) { printf("%d",octalNumber[j]); } getch(); } ```

#### Output

```Enter the decimal number 20 Its equivalent octal number is = 24 ```

#### decimal to octal in c++

``` #include<iostream> #include<conio.h> using namespace std; void main() { int octalNumber[100]; int decimalNumber,count=0; cout<<"Enter the decimal number \n"; cin>>decimalNumber; for(int i=0;decimalNumber>0;i++) { octalNumber[i]=decimalNumber%8; decimalNumber/=8; count++; } cout<<"Its equivalent octal number is = "; for(int j=count-1;j>=0;j--) { cout<<octalNumber[j]; } getch(); } ```

#### Output

```Enter the decimal number 30 Its equivalent octal number is = 36 ```

#### decimal to octal in c#

``` using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConvertDecimalToOctal { class Program { static void Main(string[] args) { int[] octalNumber=new int[100]; int decimalNumber,count=0; Console.WriteLine("Enter the decimal number"); decimalNumber = Convert.ToInt32(Console.ReadLine()) ; for(int i=0;decimalNumber>0;i++) { octalNumber[i]=decimalNumber%8; decimalNumber/=8; count++; } Console.Write("Its equivalent octal number is = "); for(int j=count-1;j>=0;j--) { Console.Write(octalNumber[j]); } Console.ReadLine(); } } } ```

#### Output

```Enter the decimal number 42 Its equivalent octal number is = 52 ```

#### decimal to octal in java

``` import java.util.*; class examples { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int[] octalNumber=new int[100]; int decimalNumber,count=0; System.out.println("Enter the decimal number"); decimalNumber = sc.nextInt(); for(int i=0;decimalNumber>0;i++) { octalNumber[i]=decimalNumber%8; decimalNumber/=8; count++; } System.out.print("Its equivalent octal number is = "); for(int j=count-1;j>=0;j--) { System.out.print(octalNumber[j]); } } } ```

#### Output

```Enter the decimal number 33 Its equivalent octal number is = 41 ```

### Write a comment

Name Email Message