C programming language programming homework help

Solve the problem shown in the image,