The file ans.sty provides a mechanism for writing exercises with answers, with the answers being printed later in the document. Its use is explained in ansdoc.tex, and onceexam.tex is an example of using one of the options in ans.sty.