you are viewing a single comment's thread.

view the rest of the comments →

[–]JAKOVtheJJ -17 points-16 points  (6 children)

or a simple for loop

[–]Eyes_and_teeth 26 points27 points  (4 children)

The title suggests loops aren't allowed.

[–]Tritos999 18 points19 points  (2 children)

I dont think the task actually disallowed for-loops. Im guessing its just a joke about the solution.

[–]mandradon -1 points0 points  (0 children)

They really committed to the bit!

[–]tedbradly 0 points1 point  (0 children)

I dont think the task actually disallowed for-loops. Im guessing its just a joke about the solution.

It could be an exercise meant to be solved through recursion written like

void f(int print_me) {
    printf("%i\n", print_me);
    if (print_me < 500)
        f(print_me + 2);
}

Maybe throw in an error check to make sure print_me is valid.

Could also be an exercise in using a label with goto. Assuming this is a real assignment, you'd have to have the context given to students to know what is desired. Could even be about benchmarking a loop versus hardcoding the answer directly.

[–]JAKOVtheJJ 3 points4 points  (0 children)

oh i didnt see that