C# Program to convert Decimal to Binary
C# Programming Language / Loop control in C# Language
341Program:
using System; public class ConversionExample { public static void Main(string[] args) { int n, i; int[] a = new int[10]; Console.Write("Enter the number to convert: "); n= int.Parse(Console.ReadLine()); for(i=0; n>0; i++) { a[i]=n%2; n= n/2; } Console.Write("Binary of the given number= "); for(i=i-1 ;i>=0 ;i--) { Console.Write(a[i]); } } }
Output:
Enter the number to convert:10 Binary of the given number= 1010
Explanation:
None
This Particular section is dedicated to Programs only. If you want learn more about C# Programming Language. Then you can visit below links to get more depth on this subject.
# C Tutorials
# JAVA Tutorials
# HTML Tutorials
# Computer Fundamental
# Data Structure
# DBMS Tutorials
SQL
# C# Language
# R Language
# PHP
# Python
# Vue JS