Help with for loop

Print positive integers to the screen. These integers should be less
than 100, and are the multiple of 3, 5 or 7. In your program, you
use setw(4) in cout for printing the numbers.
Write one program using for loop , and
another program using do…while loop

I have tried multiple attempts. I understand the basic of for loop, but how do i set the condition to allow multple conditions. PLEASE HELP!
by using || (OR) operators in your condition.
Try this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
    int i;
    for(i=3;i<100;i++)
    {
        if(i%3==0) cout<<setw(4)<<i<<endl;
        if(i%5==0) cout<<setw(4)<<i<<endl;
        if(i%7==0) cout<<setw(4)<<i<<endl;

    }
    return 0;
}
Topic archived. No new replies allowed.