Cognizant interview question

Write a code for star based pattern