Can you show us your code? I don't know what your question is besides that the output is wrong. Show us the code and we can help. How can we help you if we don't know what your even talking about.
Well, there's no need for an array.
As a first step, create a loop which will simply output all the numbers in the range M to N. When you have that working, add a test to determine whether or not each number is prime, and thus either print or ignore that number.
The previously posted code at least gives you an overview of the sort of logical flow which is required - though some of it would be simpler in C++.
Remember, this being homework, @Albo Coder should at least give some indication that he has tried it himself, otherwise how is anyone supposed to learn?