Hello guy, I was wondering what is another way to print integer while using "ONE" for loop, BUT without if and conditional operator. I can't figure it out the logical way to do it. for example, here a small code with if statement I know so far.
1 2 3 4 5 6 7 8
for(int i= number here; conditional here; insert update here)
{
if(true statement) \\ this shouldn't be here.
cout << i << " ";
}
So say I print integer like just prime, perfect, odd, or even number. That easy to do with if/ conditional operator but without it. It difficult. So I don't know what another way to do it while using for loop
With prime numbers, you run into the intrinsic issue that, well, it's not possible (as far as we know - mathematicians are still hard at work). You could loop through a pre-existing list, though: http://ideone.com/oIzUse
Almost somewhat. I'm trying to print odd integer when I output the min and max range. I made for loop for true statement and I could add if statement inside the for loop to keep the loop going so it doesn't show any even integer when I input first. ex. (if ( integer % 2 == 0)). That easy right, but without the if/conditional operator I couldn't think of other logic way to do that.
I don't think you understand. The first for loop prints only even numbers, and the second prints only odd numbers. I just combined them into one example for convenience - you don't need both of them together.