> Add the required checking and sort the numbers before you print them.

Um, why? This looks like a homework assignment that YOU have been given to do.
So you should do it, or at least fess up that you want some help.

> Could you think of a better strategy for generating the 6 different numbers?

Yep, but that's not the question is it? The question is whether or not YOU can think of a better strategy.
Can you? For example suppose I want 6 unique numbers and I think of 20, 17, 9, 41, 17...stop right there. How would I know that 17 is a duplicate?