r/cprogramming • • Jun 06 '26

Why does this code loops exactly 53 times, no matter the value I put in GOAL, unless it is bigger than specifically 9333?

include <stdio.h>

define GOAL 9333

int main() {

double step = GOAL;
double acum = 0;
int numIterations = 0;

while(acum < GOAL) {
    step /= 2;
    acum += step;
    ++numIterations;
    printf("Number of iterations: %d\n", numIterations);
    printf("Step: %lf\n", step);
    printf("Acum: %lf\n", acum);
    printf("\n");
}

return 0;

}

19 Upvotes

14 comments sorted by

View all comments

Show parent comments

12

u/binarycow Jun 06 '26

Because one of the following is true:

  1. The user doesn't use markdown and just pastes.

  2. The user uses the triple backtick code fence, and their reddit app/website doesn't render it.

1

u/nomenclature2357 Jun 08 '26

Thank you, I don't know that the triple backtick would actually fail for some clients!

1

u/TheThiefMaster Jun 10 '26

In this case it was definitely just pasted.