So to make th program do what you want it to, you have to change this line:
1 2 3 4
for(n=0;n<m;n++)
{
std::cout << n << std::endl;
}
So what does this code do? Well it loops starting from n=0, increasing n by 1 each time until
n < m becomes false.
What you want to do is n to start at n1, increase by m until n <= n2 becomes false. If you sort this out correctly, then this program should print out the numbers you want.
The only other thing you'll have to add is some code to count the number of numbers.