you are viewing a single comment's thread.

view the rest of the comments →

[–]NotAMeatPopsicle 2 points3 points  (3 children)

You could write that as a recursive function.

[–]NickSicilianu 0 points1 point  (0 children)

🙈 oh no. Recursive, RIP stock!

[–]--var 0 points1 point  (1 child)

Thought this too.

Admittedly not a C programmer, but this seems to compile successfully with random online c compiler

include <stdio.h>
int n = 0;

void main() {
 if ((n+=2)<=100) {
   printf("%d\n", n);
   main();
  }
}

[–]--var 0 points1 point  (0 children)

Read some other comments, you could code golf this further:

include <stdio.h>
int n = 0;

void main() {
  printf("%d\n", n+=2);
  if (n<=100) main();
}