iGATES Interview Question

code in c , cpp, c# and java