Knorr-Bremse Interview Question

it was a cpp/c problem but easy.