Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
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 feedbackCoaching1:1 coaching with people at your target companiesSuccess 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

Embedded C Debugging and Output

MediumSecurity & Infrastructure00:00
Practice interviewer
In session
5 left
00:00

Your question is Embedded C Debugging and Output. 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

AMD's embedded C interview loop likes to combine "what's wrong with this" with "what does it print" in the same snippet, since firmware bugs often compile cleanly and just produce quietly wrong numbers. Here is the snippet.

#include <stdio.h>

int classify(int value) {
    int result;
    if (value = 0) {
        result = 1;
    } else {
        result = 0;
    }
    return result;
}

unsigned char accumulate(void) {
    unsigned char total = 0;
    for (unsigned char i = 0; i < 10; i++) {
        total = total + 30;
    }
    return total;
}

int average_of_three(int a, int b, int c) {
    return (a + b + c) / 3;
}

int main(void) {
    printf("classify(5) = %d
", classify(5));
    printf("classify(0) = %d
", classify(0));
    printf("accumulate() = %u
", accumulate());
    printf("average = %d
", average_of_three(7, 8, 8));
    return 0;
}

What's wrong with this code, and what is the exact output when it runs? Explain each issue and trace through the program to give the precise printed values -- this compiles and runs without crashing, so you need to reason about what it actually produces, not just spot that something looks off.