Dyskusje Q&A
Can 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 głosów
8 odpowiedzicanvas
2 głosów
3 odpowiedziexplanation plzzzz!!!
0 głosów
2 odpowiedziIn 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 Głos
3 odpowiedziPopularne dzisiaj
Learn python
2 Votes
Help for study
1 Votes
Spying on me
1 Votes
Where's PHP and Ruby courses?
1 Votes
Detach thread exception
1 Votes
Qt timer timeout
0 Votes
Not video
0 Votes
Not image in the page
0 Votes