main is where your code starts, but it is not where execution starts. Something runs before it. On a hosted system the OS loads the binary and jumps to the C runtime startup code (often called crt0), which is linked in automatically: it sets up the stack, initializes global data, wires up argc/argv, and only then calls main. When main returns, that same runtime takes the integer you returned and hands it to the OS as the process exit status. On bare-metal embedded the same idea holds with no OS involved, and this is the version interviewers are usually probing for. At reset the CPU loads the initial stack pointer and the reset vector from the vector table at the start of flash, and jumps to the startup code. That code copies initialized globals (.data) from flash into RAM, zeroes the .bss section so uninitialized globals really do start at zero, optionally sets up the clock tree, and then calls main. That's why a global appears to be zero "for free", something explicitly wrote those bytes before main ran. And on embedded main is typically declared to never return: there's no OS to return an exit code to, so it ends in an infinite loop, and a main that falls off the end lands in a trap handler or resets the chip.
Programming Fundamentals · Interview question
What is main and who calls it?
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
What Is a Program?
A program is text on disk until you compile it. Walk through the source → compile → run loop you'll repeat thousands of times.