Making loop with skipping an argument

Hello. I need some help with making loops. I'm just starting with programming. Let's say I have a code like that

1
2
3
4
5
6
7
8
9
10
11
12
  #include <iostream>
using namespace std;
main ()
{
     int n;
     for (n=-4; n<15; n=n+3)
     {
         cout<<n<<", ";
         }
     system ("pause");
     return 0;
}


or

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
using namespace std;
main()
{
      int n=-4;
      while (n<15)
      {
            cout<<n<<", ";
            n=n+3;
            }
      system ("pause");
      return 0;
}


From both codes I get numbers


-4, -1, 2, 5, 8, 11, 14



First of all, I need a code that would skip the numbers 2 and 8. I have no idea how to do it.

Secondly, how to make a loop which will show the amount of numbers depending on how much I want? Not until the condition/expression will be false. For example I want to see 10 numbers straight.
Question
Why skip 2 and 8, how must the sequence of the numbers be?

as for the amount of numbers depending on how many you want there is lots of ways to do that

1. asking the user how many then using that number
2. using an infinite loop and pausing the number shown for some seconds to so the numbers won't fill up the whole screen and give you a chance to break out when once you have all the digits needed.
I need a code that would skip the numbers 2 and 8.
1
2
3
4
5
6
7
8
9
10
11
for (n=-4; n<15; n=n+3)  {
    if (n == 2 || n == 8)
        continue;
    cout<<n<<", ";
}
//or
while (n<15)   {
    if (n != 2 && n != 8)
        cout<<n<<", ";
    n=n+3;
}
I want to see 10 numbers straight.
1
2
3
4
5
6
7
int n = -4;
int printed = 0;
while(printed < 10) {
    std::cout << n;
    ++printed;
    n +=3;
}
Thank you both, finally I can continue my work on studying C++ :)
Topic archived. No new replies allowed.