NTT DATA Interview Question

some scenario is explained and asked me to code in c.