99, counting down by 3s, proposed solution


#1

Here’s what I came up with:

#include <stdio.h>

int main(int argc, const char * argv[]) {

    for (int i = 99; i > -1; i--) {
        if (i % 3 == 0) {
            printf("%d\n", i);
            if (i % 5 == 0) {
                printf("- Found one!\n");
            }
        }
    }
    return 0;
}

The printout looks good. Any room for improvement?


#2

You are counting down by 1 not by 3.


#3

//New to programming, but this works.

#include <stdio.h>

int main(int argc, const char * argv) {
// insert code here…
int x=100;
while(x>-1){
printf(“Counting %d\n”,x);
x - -;
if(x%5==0){
printf(“Found one. Number %d\n”,x);
}
x=x-2;
}
return 0;

};


#4

Sorry posted incorrectly. should be x- -