Interview Q&A · C · 10 questions in this topic

C Fundamentals — C Interview Q&A

All C topics

The vocabulary every C interview opens with — what the language is, how source becomes an executable, and the program lifecycle. Part of C Fundamentals · 202 questions in the C bank.

What is C?

Answer

C is a general-purpose, statically typed, compiled procedural programming language developed by Dennis Ritchie at Bell Labs (first released in 1972). It provides low-level access to memory through pointers, a small standard library, and maps closely onto machine behavior — which is why operating systems (Unix, Linux, Windows kernels), embedded systems, compilers and language runtimes are written in it.

C is standardized by ISO — C89/C90, C99, C11, C17 (the current baseline) and C23. Its philosophy is minimal abstraction with programmer discipline: the language trusts you, so undefined behavior is your responsibility.

Example

Example.cc
#include <stdio.h>
int main(void) {
    printf("Hello, interviewer!\n");
    return 0;
}

💡 Name one strength (portability, minimal runtime, hardware closeness) and one cost (manual memory, no safety net) — that frames every follow-up.

How does a C program go from source code to a running program?

Answer

Four stages: preprocessing (handles #include, #define, conditional compilation), compilation (each translation unit becomes assembly, then object code), linking (object files plus libraries combine into an executable), and loading/execution (the OS loader maps the binary into memory and starts main).

Most interview bugs live at a specific stage: a missing header is preprocessing, a type error is compilation, an undefined reference is linking, and a segfault is runtime.

Key points

  1. 1Preprocessing — expands #include files and macros into a translation unit.
  2. 2Compilation — each .c file compiles independently to a .o object file.
  3. 3Linking — resolves symbols across object files and libraries into one binary.
  4. 4Loading — the OS loads the binary; execution starts at main().

Example

Example.cc
/* a.c */
int add(int a, int b) { return a + b; }
/* main.c */
int add(int a, int b); /* declaration */
int main(void) { return add(2, 3); }
/* build: gcc -c a.c; gcc -c main.c; gcc a.o main.o -o app */

💡 Saying undefined reference is a linker error (not a compiler error) signals you have actually built multi-file C programs.

What are the valid signatures of main and what can it return?

Answer

The hosted-environment signatures are int main(void) and int main(int argc, char *argv[]). Returning 0 (or falling off the end of main, which implicitly returns 0 since C99) means success; returning non-zero (commonly EXIT_FAILURE from <stdlib.h>) signals failure to the OS.

argc counts the program name plus arguments, and argv[argc] is guaranteed to be NULL.

Example

Example.cc
#include <stdio.h>
int main(int argc, char *argv[]) {
    printf("args: %d\n", argc);
    for (int i = 0; i < argc; i++)
        printf("%s\n", argv[i]);
    return 0;
}

💡 Mention that falling off main returns 0 implicitly — interviewers sometimes probe exactly that.

Recommended resourcesAffiliate links · may earn us a commission

Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Cloud hosting for side projectsShip the portfolio project that gets you hired — free credits for new accounts.Claim credits