Input output statement

why after cout we are using n-1 at last what was the use of it please explain me

you are talking about this
image
line no 29?

this is the part of while loop

if don’t decrease the N then N will never decrease (condition N>0 always holds true ) and you always go inside loop and stuck in infinite loop