Write a C# Program to Convert Decimal to Octal Number

using Newtonsoft.Json.Linq;

using System;

using System.Diagnostics;

using System.Text.RegularExpressions;

using System.Xml;

using System.Xml.Linq;

public class Program

{

    public static void Main(String[] args)

    {

        int DecimalNum, quotient, i = 0, j;

        int[] octalNum = new int[100];

        Console.WriteLine("Enter The Decimal Number : ");

        DecimalNum = Convert.ToInt32(Console.ReadLine());

        quotient = DecimalNum;

        while (quotient != 0)

        {

            octalNum[i] = quotient % 8;

            quotient = quotient / 8;

            i++;

        }

        Console.Write("Octal Number is : ");

        for (j = i - 1; j >= 0; j--)

         { 

       Console.Write(octalNum[j]);

         }

        Console.ReadKey();

    }

}

Output:-

Enter The Decimal Number :

55

Octal Number is : 67

एक टिप्पणी भेजें

0 टिप्पणियाँ