0
Can u guys pls explain me why this code is not working as i wished to...(logical explanation)
I have an array that has 10 elements ... i wanna print that array which is shown in reverse way ...like 1,2,3 to be 3,2,1....... if anyone can explain me why is not working that way , i would be very grateful ...thanks in advance N.B.:HIGHLY RECOMMEND EXPLAINAITON OF WHY IT IS NOT REVERSING VALUES RATHER THAN ALTERNATIVE SOLUTION https://code.sololearn.com/cb13ZZXz8Os8/?ref=app
5 Answers
+ 2
you loop from 0 to 9
once you go halfway on the loop
the array is already reversed
but you keep on looping
and it got reversed again.
so since your array length is 10
your loop needs to be 10 / 2 = 5
from 0 to 5 instead
+ 2
Check this code edited by me. Here I have taken another array and storing value. According to your code it will assign same value. Again check your logic then you will get what you were doing.
https://code.sololearn.com/ciGVt3bJ6O4Z/?ref=app
+ 2
https://code.sololearn.com/cMVhqVfHDx8E/?ref=app
+ 1
This reverses characters, use this to see where you have gone wrong.
Input your name for example.
https://code.sololearn.com/c0GhXhEAzvHK/?ref=app