Code Room
Code reviewMediumcr-g463
Subject Boundary conditionsLevel Mid–Senior~16 minCommon in Code quality & review interviewsIndustries Software development

Question

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.

Talk through your review
Code to reviewcpp
int count = 0;for (double t = 0.0; t <= duration; t += 0.1) {    sample(t);    count++;}
Run or narrate your approach, then ask the coach.