What went wrong with this code? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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