0
Palindromic number
In order to find out if a number is a palindromic number, the input needs to be spilt up and reversed. How do you split it? Thanks
10 Respostas
+ 3
get last digit (using %) and divide by 10 until number reach 0 ^^
+ 5
You can also try this as well...
1.Convert `n` in to string using to_string(int) function...
2.scan the string from beginning and end, up to middle..and check that if corresponding elements are equal or not..
If yes , return true
Otherwise false
+ 1
by converse operation (assuming you want to join them in reverse order):
initialize a variable to zero (or use the previous one)
for each digits, multiply the variable by 10 and add digit to it...
+ 1
you doesn't need an array if you use another variable (initialized to zero) to store the resulting reverse number: then you do both operation in once loop ;P
+ 1
Yep, thanks again!
+ 1
Muhammad Hamza use strings
It might cause a bug in your program if you use division or other ways
0
And how do you join them back?
0
Thatâs smart
Thanks!
0
Oh and what about storing the individual digits?
I understand that an array should be used, but how do you create an array thatâs just as big as the number of digits?
0
I see, thanks!