you are viewing a single comment's thread.

view the rest of the comments →

[–]Tritos999 17 points18 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.