First of all, in euclidean space, compact=closed and bounded
Suppose K is not compact, then either it is not closed or not bounded
Not bounded- consider the function ||x|| which will not be bounded
Not closed-there exists a limit point A such that x_n goes to A but A is not in K
Then you can look at the function 1/||x - A||. This will be continuous on K but unbounded since it goes to infinity as x goes to A
There are probably better proofs but this is at least the picture that should come to mind.