Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Problem: binary
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { NumbertoBinary obj = new NumbertoBinary(); Scanner input = new Scanner(System.in); int num = input.nextInt(); System.out.println("\nBinary representation of number: "); obj.convertBinary(num); } } class NumbertoBinary { public void convertBinary(int num) { int binary[] = new int[40]; int index = 0; while(num > 0) { binary[index++] = num%2; num = num/2; } for(int i = index-1;i >= 0;i--) { System.out.print(binary[i]); } } }
run
|
edit
|
history
|
help
0
Java
total a pagar
LeetCode 121 - Best time to buy and sell stock - O(n) solution
Value pair analysis
3e
queue_using_stack
Product of Array Except Self
Compare three ways to clear a String in java
Validate BST
3