Skip to content

Instantly share code, notes, and snippets.

@theArjun
Last active October 20, 2018 12:33
Show Gist options
  • Select an option

  • Save theArjun/d3eef76782ec2a069f713d4558089c23 to your computer and use it in GitHub Desktop.

Select an option

Save theArjun/d3eef76782ec2a069f713d4558089c23 to your computer and use it in GitHub Desktop.
Decimal Number To Binary Number System
class DecToBin{
public static void main(String[] args){
int dec = 64;
int bin=1,rem=0;// I assigned bin to 1 in this revision.
while(dec>1){ // I run the loop while dec is greater than 1 in this revision.
rem=dec%2;
bin=bin*10+rem;
dec=dec/2;
}
System.out.println("In Binary = "+bin);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment