both loops are approaximately same in terms of space complexity.
so, in my view both are same but, you can use that one those are easier for you.
In this case use while loop
storage space is very important but in the given for loop 'i' is an avoidable variable used
while(n!=0) would be more appropriate since the digit can be positive as well as negative.