ctr is defined as an integer with a starting value of 1. , while it's less than or equal to 20 it prints the value of ctr, then increments it... then sets it back to one?! Then it's going to print its value again, increment again, and then in that same while statement it's going to tell it to return a value of 0 if it's less than or equal to 20? It looks to my elementary knowledge like it's going to keep printing 1 and 0 over and over while never getting to a point where the while value is reached.
Have you actually compiled and run this program? What does it do, you've said what it's supposed to do. That code goes in far too many circles
