AT&T Interview Question

Solve a piece of code they provided