Saturday, 2 December 2017

C# Program to Convert Decimal to Octal


Code:

using System;
class program
{
    public static void Main()
    {
        int decimalNumber, quotient, i = 1, j;
        int[] octalNumber = new int[100];
        Console.WriteLine("Enter a Decimal Number :");
        decimalNumber = int.Parse(Console.ReadLine());
        quotient = decimalNumber;
        while (quotient != 0)
        {
            octalNumber[i++] = quotient % 8;
            quotient = quotient / 8;
        }
        Console.Write("Equivalent Octal Number is ");
        for (j = i - 1; j > 0; j--)
            Console.Write(octalNumber[j]);
        Console.Read();
    }
}


Output:

Enter a Decimal Number :
50
Equivalent Octal Number is 62


More C# Programs:




















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...