Broadcom interview question

logic quiz and to solve a problem with C program