0
What went wrong with this code?
public class Program { public static void main(String[] args) { int c=0,a,temp; int n=153; temp=n; while(n>0) { a=n%10; n=n/10; c=c+(a*a*a); } if(temp==c) { System.out.println("armstrong number"); } else { System.out.println("Not armstrong number"); } } }
3 Respostas
+ 9
I've tried to find the stupid bug and here is the finding:
Logic seems okay, but there are some invisible invalid characters which are causing errors. Erase the spaces or rewrite the codes. You can see the error logs from here:
http://ideone.com/vFfJhl
+ 3
@Shamima Yasmin is right... And you can also easily see highlighted invalid spaces by copy/pasting it in code playground and open it with internet browser ;)
+ 1
@Shamima Yasmin thanks for the help..!!