Put your values into *X and *Y somehow while (*X) { *X-- *Y-- } #if Y was greater than X it will still be postive while (*Y) { while (*Y) { #Empty Y so we can get out of the #surrounding loop *Y-- } #Do your thing here }