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");   }  } }

2nd Jul 2017, 5:00 PM
akriti more
akriti more - avatar
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
2nd Jul 2017, 6:18 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 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 ;)
2nd Jul 2017, 10:07 PM
visph
visph - avatar
+ 1
@Shamima Yasmin thanks for the help..!!
3rd Jul 2017, 12:22 AM
akriti more
akriti more - avatar