Capgemini Interview Question

Write a logic for specific case in c#