Capgemini interview question

Write a logic for specific case in c#