Cognizant Interview Question

Write a code for star based pattern