Compiler not accepting the code?

Can u plz tell the approach u have used, since I m not able to understand few lines in your code.