Print out all numbers from 1 to 100 that is divisible by 3 using a for loop just like the last problem, but this time, with each number only separated by the space like that of the sample output.
#include <iostream>
using namespace std;
int main() {
for(int i=1;i<=100;i++)
{
if (i % 3 == 0) {
cout << i<<" ";
}
}
return 0;
}
Comments
Leave a comment