Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Trending in AI
Hot
Agentic AI EngineerForward-Deployed EngineerGenAI EngineerAI Architect
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Start free

Explain This Code

MediumCoding00:00
Practice interviewer
In session
5 left
00:00

Whenever you're ready, walk me through how you'd approach this.

Sign up free to chat or submit. Log in

Problem

Alten's automotive team asked a candidate to read through this C function, taken from a simplified engine-control sample, and explain what it does before diving into the rest of the interview.

#include <stdio.h>

int compute_average_rpm(int *readings, int count) {
    int total = 0;
    for (int i = 0; i <= count; i++) {
        total = total + readings[i];
    }
    return total / count;
}

void log_reading(int rpm) {
    char buffer[8];
    sprintf(buffer, "RPM=%d", rpm);
    printf("%s
", buffer);
}

int main() {
    int readings[5] = {1200, 1250, 1300, 4200, 1225};
    int avg = compute_average_rpm(readings, 5);
    log_reading(avg);
    return 0;
}

Explain what this code does, then identify anything about it you'd flag as a bug before it went anywhere near a real engine-control unit.