CellPrint plus ExpressionCell are tools for generating cells. They do not hold their arguments, so some control of evaluation is necessary (Defer). [Update: In response to Szabolcs' comment about a default option value for CellPrint is GeneratedCell -> True (see also this comment by John Fultz), we should let options be passed.]
ClearAll[gencode];
SetAttributes[gencode, HoldAll];
gencode[code_, opts : OptionsPattern[Cell]] :=
CellPrint@ExpressionCell[Defer@code, "Input", opts];
Examples:

Or following Szabolcs:
gencode[Module[{a, b}, a = 1; b = 2; a + b], GeneratedCell -> False]
CellPrint+ExpressionCell[Defer@code, "Input"]? – Michael E2 Apr 30 '17 at 12:25