Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
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
Experiences
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
Build my plan

C Pointer Code Tracing

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

Your question is C Pointer Code Tracing. Take a moment with it on the right.

Talk me through your thinking if you like. When you're confident, submit your answer and I'll grade it like a real screen (7/10 or better passes).

You need to log in / sign up to chat or submit.

Problem

Lutron's lighting control firmware keeps dimmer levels for a room as a small array of integers, and this helper is supposed to double every level (for a "boost" scene) before the values are pushed to the wall dimmers. On the actual hardware target — a typical 64-bit platform, 8-byte pointers and 4-byte int — it doesn't boost all of them.

#include <stdio.h>

void doubleLevels(int *levels) {
    int count = sizeof(levels) / sizeof(levels[0]);

    for (int i = 0; i < count; i++) {
        levels[i] = levels[i] * 2;
    }
}

int main(void) {
    int levels[6] = {10, 20, 30, 40, 50, 60};

    doubleLevels(levels);

    for (int i = 0; i < 6; i++) {
        printf("%d ", levels[i]);
    }
    printf("
");

    return 0;
}

Assuming the stated 64-bit platform, tell me exactly what gets printed, then explain how you would modify doubleLevels so it correctly doubles every level in the array.