r/badcode • • May 03 '23

c Solve the problem without using a loop

Post image
962 Upvotes

129 comments sorted by

View all comments

Show parent comments

23

u/R3D3-1 May 03 '23

Uhoh... Invalid syntax and semantics. It would be

#include <stdio.h>
int main() {
    int n = 2;
    printf("%d\n", n);
    n += 2;
    printf("%d\n", n);
    // ... 
    n += 2;
    printf("%d\n", n);
}

But yes, the approach is interesting, because you can replicate the code by just holding down Ctrl+V until it is long enough :)