I'm REALLY not good at programming. Sometimes its hard for people to fully explain how to do something. I'm supposed to write a program that prints the integers in the range of 1 to 100 that are evenly divisible by 3 but not evenly divisible by 6. I managed to create:
The output repeats "The numbers '' '' '' for each found integer. How do I get it to only list it ONCE, and how do I get the program to keep count until the last found number?Code:#include <stdio.h> int main(void) { int i; int w = 0; for (i=1; i<=100; i++) { if(i%3 == 0 && i%6 != 0) printf("The numbers that are evenly divisible by 3 and not 6 are: %2d/3\n", i); } }
And then I have to write a similar program that, beginning with the integer 1, finds the integers that are evenly divisible by 3 or 4 and/or evenly divisible by 5 or 6. The program is supposed to stop after its found 5 integers that are divisible by 5 or 6.
Can someone please explain to me, with examples, as to what I'm missing? And how I'm supposed to do it?