JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/** It is a decimal to Binary convertor code which i tried to code.*/
/*
Please help me out to find the exact problem with this code, because all test cases are not cleared with this code.
*/
import java.util.Scanner;
public class Program {
public static void main(String[ ] args) {
int rem=0,count=0,i=1;
int [] arr = new int[10];
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
while(x>0)
{
count++;
rem=x%2;
for(;i<=count;i++)
{
arr[i]=rem;
}
x/=2;
}
for(i=count;i>0;i--)
{
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run