---
title: "C Programming Interview Questions (2026): By Level, With Model Answers"
url: https://weworkworldwide.com/c-programming-interview-questions/
description: "C interview questions for junior, mid and senior developers — pointers, memory management, undefined behaviour and the stack vs heap — with answers and red flags."
date: 2026-07-04T16:00:38+00:00
source: https://weworkworldwide.com/llms.txt
---

# C Programming Interview Questions (2026): By Level, With Model Answers

How to use this

C gives you nothing but a compiler and responsibility. These questions check whether a candidate truly understands pointers, memory and undefined behaviour.

Hiring a C developer is easy. Telling a real one from a convincing résumé is the hard part — and it’s most of what we do. These are grouped by level, because the same question that stretches a junior is a warm-up for a senior.

## Junior C interview questions

0–2 years

Fundamentals.

### What is a pointer?

What a strong answer covers

A variable holding a memory address; dereferencing it accesses the value there. Pointers enable indirection and dynamic memory.

Red flag

Confuses a pointer with the value it points to.

### What is the difference between the stack and the heap?

What a strong answer covers

The stack holds automatic, scope-bound locals and is fast; the heap is manually managed dynamic memory via `malloc`/`free`.

Red flag

Thinks all variables live in the same place.

### What does `malloc` return and what must you check?

What a strong answer covers

A pointer to uninitialised heap memory, or NULL on failure — which you must check before using.

Red flag

Uses the result of `malloc` without a NULL check.

### What is the difference between `=` and `==`?

What a strong answer covers

`=` assigns; `==` compares. Accidentally using `=` in a condition is a classic bug.

Red flag

Writes `if (x = 5)` unintentionally.

### What is an array’s relationship to a pointer?

What a strong answer covers

An array name decays to a pointer to its first element in most expressions, but they are not identical (e.g. `sizeof`).

Red flag

Thinks arrays and pointers are fully interchangeable.

### What is the difference between `char *s` and `char s[]`?

What a strong answer covers

A pointer to (often read-only) string data vs a mutable array holding a copy; modifying a string literal is undefined.

Red flag

Modifies a string literal and crashes.

### What does `const` do?

What a strong answer covers

Marks data as non-modifiable through that name, documenting and enforcing intent, including for pointer targets.

Red flag

Ignores const-correctness.

### What is the difference between `++i` and `i++`?

What a strong answer covers

Both increment; pre-increment yields the new value, post-increment the old — relevant in expressions.

Red flag

Cannot predict the value in an expression.

## Mid-level C interview questions

2–5 years

Memory and pointers.

### What is a memory leak and how does it occur?

What a strong answer covers

Heap memory allocated but never `free`d because its pointer is lost or forgotten; long-running programs degrade.

Red flag

Never frees allocated memory.

### What is a dangling pointer?

What a strong answer covers

A pointer to memory that has been freed or gone out of scope; dereferencing it is undefined behaviour.

Red flag

Uses a pointer after `free`.

### What is a buffer overflow and why is it dangerous?

What a strong answer covers

Writing past an array’s bounds, corrupting memory and a classic security vulnerability.

Red flag

Copies into a fixed buffer without bounds checking.

### What is the difference between `malloc`, `calloc` and `realloc`?

What a strong answer covers

`malloc` allocates uninitialised memory, `calloc` zero-initialises, `realloc` resizes an existing block.

Red flag

Assumes `malloc` zeroes memory.

### What is a function pointer and where is it used?

What a strong answer covers

A pointer to executable code, used for callbacks, dispatch tables and plugin-like designs.

Red flag

Never uses them and duplicates dispatch logic.

### What is the difference between pass by value and by pointer?

What a strong answer covers

C passes by value; to mutate a caller’s variable you pass its address (a pointer).

Red flag

Expects a function to modify a passed-by-value argument.

### What is `sizeof` and a common pitfall?

What a strong answer covers

A compile-time operator giving a type/object’s size; a pitfall is `sizeof` on a pointer expecting the pointed-to array size.

Red flag

Uses `sizeof(ptr)` to get array length.

### What is the difference between a shallow and deep copy of a struct?

What a strong answer covers

Copying a struct copies pointer members by value (shared targets); a deep copy duplicates what they point to.

Red flag

Copies a struct with pointers and gets double-frees.

## Senior C interview questions

5+ years

Undefined behaviour and systems.

### What is undefined behaviour and why does it matter?

What a strong answer covers

Operations the standard leaves undefined (out-of-bounds access, signed overflow, use-after-free); compilers may do anything, and it’s a top source of bugs and exploits.

Red flag

Treats a program that happens to work as correct despite UB.

### How do you debug memory errors in C?

What a strong answer covers

Tools like Valgrind and AddressSanitizer detect leaks, invalid accesses and use-after-free that are otherwise silent.

Red flag

Debugs memory corruption with print statements alone.

### What is memory alignment and struct padding?

What a strong answer covers

Types must sit at aligned addresses, so the compiler pads structs; misunderstanding it causes wasted space and portability bugs.

Red flag

Assumes struct size equals the sum of member sizes.

### What are `volatile` and `restrict` for?

What a strong answer covers

`volatile` tells the compiler a value may change outside program flow (hardware/signals); `restrict` promises non-aliasing to enable optimisation.

Red flag

Uses `volatile` as a concurrency primitive.

### How do you write portable C?

What a strong answer covers

Avoid undefined and implementation-defined behaviour, don’t assume type sizes or endianness, and use fixed-width types where needed.

Red flag

Assumes `int` is always 32 bits and pointers are 4 bytes.

### How do you manage ownership of memory in a large C codebase?

What a strong answer covers

Clear, documented ownership conventions for who allocates and frees, since the language enforces nothing.

Red flag

Ambiguous ownership leading to leaks and double-frees.

### What concurrency hazards exist in C?

What a strong answer covers

Data races on shared memory need synchronisation (mutexes, atomics); the memory model defines what’s guaranteed.

Red flag

Shares data across threads with no synchronisation.

### How do you reason about performance in C?

What a strong answer covers

Cache behaviour, memory layout, avoiding unnecessary allocations, and measuring with a profiler rather than guessing.

Red flag

Micro-optimises without profiling.

**Skip the screening entirely.**We vet C engineers so you don’t have to — embed one in your team, or have us build it.

[Hire C developers](https://weworkworldwide.com/outstaffing/)[Compare us](https://weworkworldwide.com/compare/)

Build and score a full interview with our free [interview scorecard tool](https://weworkworldwide.com/developer-interview-scorecard/), browse the [full question hub](https://weworkworldwide.com/interview-questions/), or see [how we interview engineers](https://weworkworldwide.com/how-we-interview-engineers/).
