Printing four patterns using loops