Wrong why explain please | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Wrong why explain please

import java.util.Scanner; public class Javac { public static void main(String[] args) { Scanner sc= new Scanner(System.in); int num=sc.nextInt(); System.out.print(convert(num)); } public static int convert(int num) { int dec=0; int i=0; while(num>0) { int temp=num%10; // dec+=(temp*Math.pow(2, i)); num=num/10; i++; } return dec; } } // if i write like this //dec=dec+(temp*Math.pow(2, i)); //why is not work //

21st Apr 2021, 10:39 AM
Sachin Saxena
Sachin Saxena - avatar
1 Answer
0
It is working fine. In terms of syntax
21st Apr 2021, 1:47 PM
Atul [Inactive]