IFS interview question

Q: Write code for a given scenario (using for loops)