iGATES interview question

code in c , cpp, c# and java