What is the difference between Temptation and Sin?

We are all tempted at various circumstances. We cannot always prevent temptations, but we can surely prevent sin.

Jesus was tempted by the devil in the wilderness, but He did not yield to it. Instead of yielding, He rebuked and confronted the devil with God's Word. 

For example, anger can be a temptation. Being angry is not a sin, but reacting to it in an ungodly manner is a sin. When you get angry because of another people, you must not react to it by throwing harsh words on them or beating them up, but be still and seek God's help to forgive and forget. 

Ephesians 4:26

“Be ye angry, and sin not: let not the sun go down upon your wrath:”

Psalm 4:4

King James Bible
Stand in awe, and sin not: commune with your own heart upon your bed, and be still. Selah.

New King James Version
Be angry, and do not sin. Meditate within your heart on your bed, and be still. Selah

Let's say you are a chocolate lover and you want to avoid chocolates and deserts to stay healthy. When you accidentally see a poster with your favorite chocolate or desert, you get tempted. Now, accidentally seeing that poster is not your fault. But, after seeing, you should divert your mind from it and walk away. Instead of walking away, if you get into the desert shop and eat the chocolates and deserts, it is your fault.

Temptation is not sin, while yielding to it and staying in it is.