If you are placing your JavaScript in a <script> element, then the </script> in the string literal will be recognised as a matching end tag for the script. Break up the string with an escape sequence (in a JS string literal, \/ means the same as /):
$('.printed-code').val('<script> write your code between these lines <\/script>');
… or keep the script in an external file and reference it with <script src="foo.js"></script>.
If you want to display information to a user, then you shouldn't be using an <input> to do so, so you will be wanting the text() method, not the val() method. (Assuming .printed-code matches a <code> element or something else that is appropriate for the task at hand).
$('code.printed-code').text('<script> write your code between these lines </script>');
pretags, and show code.