Following C# program is to convert the Decimal number into Binary number,
Program:
using System;
public class Program
{
public static void Main()
{
int i=1, binary=0;
int rem, num;
Console.WriteLine('Enter a decimal number');
num=int.Parse(Console.ReadLine());
while(num!=0)
{
rem=num%2;
num=num/2;
binary=binary+(rem*i);
i=i*10;
}
Console.WriteLine('Binary number is :'+binary);
}
}
Output:
Enter a decimal number
20
Binary number is :10100
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Following C# program is to convert the Decimal number into Binary number,
Program:
Output: