Core CS · 12 Questions

Top C Systems Programming Interview Questions

Essential low-level systems questions testing memory address manipulation, pointers, bitwise arithmetic, and operating system interfaces.

Q1 Medium

What is the purpose of the 'volatile' keyword in C?

The volatile keyword informs the compiler that a variable's value may change at any time from outside the current code flow (e.g. by hardware registers, interrupt service routines, or another thread). This prevents the compiler from optimizing reads into CPU registers.

Solution Code
// Memory-mapped hardware status register
volatile uint32_t *status_reg = (uint32_t *)0x40001000;
while (*status_reg == 0) {
    // Compiler must re-read from memory on every loop iteration
}
Q2 Easy

What is a memory leak and how do you prevent it in C?

A memory leak occurs when dynamically allocated memory (via malloc, calloc, realloc) loses all pointers referencing it without being released via free(). Over time, leaked memory exhausts system RAM. Prevent it by always pairing allocations with deallocations and verifying with tools like Valgrind.

Q3 Medium

What is the difference between char str[] = "hello"; and char *str = "hello";?

char str[] creates a mutable array on the stack initialized with the string characters. char *str creates a pointer to a string literal stored in read-only memory (.rodata section). Attempting to modify characters in char *str causes a Segmentation Fault.

Solution Code
char arr[] = "hello";
arr[0] = 'H'; // Perfectly valid

char *ptr = "hello";
// ptr[0] = 'H'; // UNDEFINED BEHAVIOR / SIGSEGV

Prepare for Live Technical Interviews

At DoxaTech Hub, students receive mock interview drills, resume reviews, and direct coaching to ensure they pass rigorous engineering screens.

Join DoxaTech Today