Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuiteDiscussions Q&R
canvas
2 Votes
3 RéponsesCan someone explain this code to me....
class ReverseNumberDemo
{ public static void main(String args[]) {
int num=123456789;
int reversenum =0;
while( num != 0 ) {
reversenum = reversenum * 10;
reversenum = reversenum + num%10;
num = num/10; }
System.out.println("Reverse of specified number is: "+reversenum);
}
}
the thing I don't get is the reversenum part......isn't reversenum=0 so wouldn't reversenum*10=0
0 Vote
8 Réponsesexplanation plzzzz!!!
0 Vote
2 RéponsesIn the continue Loop -
i = 0
while True:
i = i +1
if i == 2:
print("Skipping 2")
continue
if i == 5:
print("Breaking")
break
print(i)
print("Finished")
It shows the output being
"1
Skipping 2
3
4
Breaking
Finished"
Why are the last three lines not
"Breaking
5
Finished"
Where it shows print(i) after break?
1 Vote
3 RéponsesAujourd'hui en vedette
Media on HTML
0 Votes
Code Playground
0 Votes
xampp
0 Votes
Is Sololearn better or Mimo.org?
1 Votes
Editor HTML
0 Votes
How to solve this
1 Votes
Java project
0 Votes