i believe every programmers here must have time when feeling panic, or getting stuck in programming...just wondering what you doing when having this situation.... feel free to drop your experience or comment here...
At work, continue working on something else. At home, go to sleep.
The next time you get back to the code (or when you wake up), the solution to the problem will often be obvious (be it an unresolved bug or a matter of design).
This topic should really be in the lounge, not the beginners forum (not intended to sound mean or condecending; just for future reference)
When I have a problem with some code, I'll try debugging for a few minutes. When I can't think of anything else to do, and if the problem still exists, I do something else for a while, like listening to music (I find that helps me the most) or taking a short walk.
If I am stuck because I don't know how to proceed, I grab a teammate or two, walk up to whiteboard or into a small conference room, and discuss the problem I am facing. Software development (in the jobs I've had) is a group effort.
If I am stuck because I don't feel like working, I grab a coffee.
In the summer-time I'll hop on my kawasaki and go for a ride to clear my head. In the winter-time, I'll usually just have a drink and turn on netflix until it clicks.
I just let my cat walk all over my keyboard and force myself to figure out what was meant to be there and what wasn't. Usually I end up finding the bug. :)
No, seriously. If I find myself seriously stuck (which thankfully doesn't happen to often), I take a break from the project for up to a week, then come back to it and try the problem from a completely different angle.
The thing is that when your brain tries to do something, it tends to make deeper the wrong idea, instead of thinking in something else. Well at least it happens to me.
I agree with what mostly everyone else has said. Do something else for a while and then go back to it. (including going to sleep and waking up the next morning)
By the way, This is all assuming you have the time to do so, deadline wise.