Siemens interview question

Write program for some suitation