My code is not giving correct answer

Here is my code: https://ide.codingblocks.com/s/221728
Please make changes in my code and mention that

@navin_japes
your code have lots of mistakes. I am pointing out those mistakes

  1. You have not considered the case when ans doesn’t exist, you have to print “-1” in that case.
  2. you have to temp1->data == temp2->data, their data may be same but temp1 and temp2 are always different.
  3. move the longer linked list ahead by different of their length before entering in while loop.

I made few changes in your code, it’ll work fine now

Thanks brother it is correct very much