Code RoomFloating point loop count
MediumPrep Room Coding #2088

Floating point loop count

Code reviewCode quality & reviewMid–Senior~16 min

Review this C++ loop that samples a signal at every 0.1s from 0 to a duration and counts the samples.

For `duration = 1.0`, the team expects 11 samples (0.0 .. 1.0).

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 16 min
Mark a line and say what kind of problem it is.0 findings
1int count = 0;
2for (double t = 0.0; t <= duration; t += 0.1) {
3 sample(t);
4 count++;
5}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.