Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
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..!!