To be more clear:
for( int i = 0 ; i < n ; i++ )
cin >>num ;
You are over-writing the inputs here. In
num
, only the last one remains.
What is being suggested is to use an array instead. Store all the inputs and then try to reverse them.
BTW, it looks like that you got this code to from somewhere that reverses a number. This observation is based on the return type of your
reverse()
method and the way you use it in
Main()
.
In order to reverse all the numbers that are input and then print it out, you need to make the change to method return type too.