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>
usingnamespace 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>
usingnamespace 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.