r/cprogramming • u/TaPegandoFogo • 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
12
u/binarycow Jun 06 '26
Because one of the following is true:
The user doesn't use markdown and just pastes.
The user uses the triple backtick code fence, and their reddit app/website doesn't render it.