programming-examples/c-sharp/Conversions/C# Program to Convert Decimal to Octal.cs

30 lines
752 B
C#
Raw Normal View History

2019-11-15 12:59:38 +01:00
/*
* C# Program to Convert Decimal to Octal
*/
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();
}
}
/*
Enter a Decimal Number :
50
Equivalent Octal Number is 62