Siemens interview question

Technical questions with example using code