I attached a diagram for you to easily visualize this problem.
To solve this problem, you would use the pythagorean theorem. The 12-ft ladder is the hypotenuse and the 3 ft from the barn is one of the side legs. You want to find the length of the "other side leg", or the height of the barn.
Substitute 3, 12, and x into the pythagorean theorem like so.