You can use the for loop. The question is, what should it do?
You, as user, have given value 7 and the program has stored it in variable A.
Your test on line 9 has confirmed that value 7 is valid (odd and within range [7..23].
Your for loop will continue as long as A is less than 23 and increment the A by one after each iteration. If the A is odd, then you print a symbol.
Note that we know that A is odd at start. If we keep incrementing it by 2 rather than 1, then the A is odd on every iteration and we don't have to test that separately.
1 2 3 4 5
|
while ( A < 23 )
{
cout << A << '\n' ;
A += 2;
}
|
or
1 2 3 4
|
for ( ; A < 23; A += 2 )
{
cout << A << '\n' ;
}
|
There are eight odd values: {7, 9, 11, 13, 15, 17, 19, 21} (starting from 7 and less than 23).
We get back to the question: why do you have the
A > 7
in your for loop, as an init-expression. It does not do anything there.
Why are the 7 and 23 valid inputs? Is the intention that the 23 is valid, but produces 0 symbols?