3Di interview question

Basic program and pseudo code