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
HTML
1 Votes
Formating in python
0 Votes
Could you ple ase help me???
0 Votes
What's wrong here?
0 Votes
Header, Main, Footer
0 Votes
Wifi Password
0 Votes
How to grow in sololearn
0 Votes