Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace DecimalToBinary
- {
- class Project1
- {
- void Main()
- {
- int x,binary=0,t=1;
- Console.Write("Enter a number : ");
- x=Convert.ToInt32(Console.ReadLine());
- while(x!=0){
- if(x%2==1){
- binary+=t;}
- x/=2;
- t*=10;
- }
- Console.Write("Number in binary : {0}",binary);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment