 # C# Convert Decimal to Binary

## Convert Decimal to Binary

We can convert any decimal number in to binary number.

## Decimal Number

Decimal number is a base 10 and there are total 10 digit. Because this range from (0 to 9).

Example: Decimal number is 342 654 344 455

## Binary Number

Binary number is a base 2 and there are total 2 digit. Because this range from (0 to 1).

Example : Binary number is 01010 010010 10001 010101

## Decimal Binary

1.                   0

2.                   10

3.                   11

4.                   100

5.                   101

6.                   110

7.                   111

8.                   1000

9.                   1001

10.                 1010

## Write a program convert Decimal to Binary

1. using System;
2. public class Convert {
3. public static void main (string[] args)
4. {
5. Int n,i
6. int [] a = new int
7. Console.Write("Enter a Numbe");
9. for(i=0; n&gt;0; I++){
10. a[i] = n%2;
11. n = n/2;
12. }
13. Console.Writeline("binary value");
14. for(i=i-1 ;i&gt;=0 ;i--){
15. Console.Write(a[i]);
16. }
17. }
18. }

## Output:

Enter a number: 8

Binary value : 1000 Author
##### Top 10
Blogger Top 10 content related post