There are two major aspects in the difference between good code and bad code. The two differences are style and intent. Style in fashion is one thing but in reference to code it is all about programming. Now in regards to intent, it is so linked to style until it seems one can't be good without the other because it all boils down to good or bad readability. One can always recognize good code because there is very little effort for a reader to understand the intent of the author. Also, considering it from the machine aspect, good code uses less resources and less time for a task to process. Good code's individual parts are of high quality and fits together well and runs smoothly; whereas, bad code has shoddy individual parts that are jammed together. Listed below are additional differences between good code and bad code.
Good Code
Bad Code
You can find many examples of bad codes here: crapcodes.com