Write a code to print all numbers that are multiples of 3 between 1-100
Problem-solving ideas:
1. A multiple of 3 must be divisible by 3, so when the expression i%3==0 is true, then i must be a multiple of 3
2. To output multiples of 3 between 1 and 100, you only need to loop 100 times from 1 to 100, and after each time you get i, use i%3==0 to detect
If true: i is a multiple of 3, output
If false: i is not a multiple of 3
#include <stdio.h>
int main()
{
int i = 0;
for(i=1; i<=100; i++)
{
if(i%3==0)
{
printf("%d ", i);
}
}
return 0;
}