TAVISUAL - Wrong Answer

I am getting a wrong answer when I submit this code.Could someone please tell me where I am going wrong?
Thanks in advance.

Following is the link to my code : http://ideone.com/cO5xHf

Hi! the mistake is you are not checking whether the present value of c is in the range[l,r] or not.

You can check my solution here

http://www.codechef.com/viewsolution/3335950

thanks a lot!so stupid of me.

//