C Programming
0Loading crowd target
0Loading crowd target
7correct to beat the crowd
50 free C Programming trivia questions with answers — science & nature quiz, new questions added Oct 2026.
C is more than fifty years old and still sits underneath the software most of us use every day. Operating systems, game engines, databases and the interpreters for newer languages are written in it, which is why a working knowledge of C keeps turning up in computer science courses and job interviews. This quiz covers the ground a C test usually covers: the basics of syntax and data types, the operators that trip people up, pointers, strings and dynamic memory allocation, and the bugs that come from getting them wrong. It also asks about the people and places behind the language, and includes a run of questions on its two best-known descendants, C++ and C#. The questions are multiple choice and range from first-week material to the sort of detail an interviewer likes to probe. Each answer comes with a short explanation, so the quiz works as revision for students, a warm-up before a technical interview, or a puzzle for anyone who writes code.
30 of 50 questions with answers and explanations. Play the quiz
Q 01Which creator of the C programming language died in October 2011, only days after Apple co-founder Steve Jobs?
Dennis Ritchie
Dennis Ritchie was found dead at his New Jersey home on October 12, 2011, aged 70. Steve Jobs had died seven days earlier, on October 5.
Q 02The default and most widely used interpreter for which language, created by Guido van Rossum, is written in C?
Python
Python's standard interpreter is named CPython for exactly that reason. A rival implementation, PyPy, is written in a restricted dialect of the language itself.
Q 03Which operating system kernel, begun by a Finnish university student in 1991, is written mostly in C?
Linux
Linux was started by Linus Torvalds at the University of Helsinki, who announced it online as "just a hobby, won't be big and professional". Most of its kernel code is still C.
Q 04Which Epic Games engine, first built for a 1998 first-person shooter, is written in C++?
Unreal
Unreal Engine takes its name from Unreal, the 1998 shooter it was made for. Epic founder Tim Sweeney began developing it in 1995.
Q 05The "sharp" in the name of the C# programming language was borrowed from which field?
Musical notation
Musical notation uses a sharp sign to raise a note by a semitone, so C# hints at a step up from C. The name is typed with a number sign because most keyboards lack the true sharp symbol.
Q 06The 1978 book The C Programming Language made which phrase the traditional output of a first program?
Hello, world
"Hello, world" was printed by the book's opening example, and programming tutorials have copied it ever since. Co-author Brian Kernighan had already used the phrase in a 1974 in-house memo.
Q 07C was developed as the successor to which earlier language, written by Ken Thompson around 1969?
B
B was typeless, treating every value as a machine word, a weakness that pushed its authors to build an expanded version with types. That expanded version became C.
Q 08The "++" in the name C++ is a programmer's joke based on which operator of the C language?
Increment
Increment is what ++ does in C, adding one to a variable, so the name suggests C taken one step further. The language was briefly called C84 before the new name stuck.
Q 09Which operating system was rewritten from assembly language into C in 1973, helping it spread to other computers?
Unix
Unix had first been written in assembly for the PDP-7, which tied it to that one machine. Once nearly all of it was in C, it could be moved to new hardware far more easily.
Q 10Which technology company introduced the C# language in 2000, with a design team led by Anders Hejlsberg?
Microsoft
Microsoft first showed C# to developers in July 2000. It considered keeping the working name COOL, but dropped the idea for trademark reasons.
Q 11A C program starts running in which function, whose return value becomes the program's exit status?
main
The main function can take no parameters or two, which carry the command-line arguments. Since the C99 standard, reaching its closing brace without a return statement counts as reporting success.
Q 12Which C standard library function writes text to the screen, filling placeholders such as %s with values?
printf
The name printf stands for "print formatted". The function also hands back the number of characters it wrote, or a negative value if the output failed.
Q 13Which header file must a C program include before calling input and output functions such as puts and getchar?
stdio.h
The stdio.h header also defines the FILE type, which holds everything needed to control a stream. The same header therefore covers reading and writing files on disk.
Q 21Which C standard library function reserves a requested number of bytes and leaves their contents uninitialised?
malloc
A call to malloc hands back a null pointer when the request cannot be met, so careful code tests the result before using it. The block stays reserved until the program explicitly gives it up.
Q 22Which C allocation function takes an element count and an element size, and sets every byte it returns to zero?
calloc
Because calloc clears the whole block, an array it returns can be read straight away. It also does the count-times-size multiplication itself instead of leaving it to the caller.
Q 23Which C function changes the size of an existing allocation, moving the data to a new address if it must?
realloc
Q 14In C, C++ and C#, which punctuation mark ends a statement, so that a missing one stops the program compiling?
Semicolon
Semicolon endings mean the compiler ignores where a line stops, so one statement can run across several lines. Groups of statements are then bundled into blocks with curly braces.
Q 15Arrays in C, like those in most languages descended from it, number their first element with which index?
0
0 is the first index because a subscript in C is really an offset from the start of the array, and the opening element sits at no offset at all.
Q 16In C, a single equals sign assigns a value; which operator tests whether two values are equal?
==
The == operator is easy to mistype as a lone equals sign, which assigns instead of comparing. In many cases that slip compiles without any error message.
Q 17Which C operator, written between two integers, gives the remainder left after dividing the first by the second?
%
The % operator yields only the leftover, so 17 % 5 is 2. If the right-hand value is zero, the C standard leaves the behaviour undefined.
Q 18In a C switch statement, which keyword stops execution from falling through into the next case?
break
A break exits the switch at once; without it, C simply carries on into the code of the following case. That fall-through is legal, so a forgotten one compiles cleanly.
Q 19Which C loop tests its condition only after each pass, so its body always runs at least once?
do-while
A do-while loop puts its test at the bottom, after the body has already run. The plain while loop checks before the first pass, so it may never run at all.
Q 20Which C keyword, written in place of a return type, declares that a function gives back no value?
void
The void keyword was missing from the earliest versions of C, where a function with no stated result simply defaulted to returning an int.
A realloc call keeps the old contents up to the smaller of the two sizes. If memory runs out it returns a null pointer and leaves the original block intact.
Q 24In C, memory requested at run time comes from which region, as opposed to the stack used for local variables?
The heap
The heap is an area set aside for this purpose, and a block taken from it stays reserved until the program hands it back. Automatic variables instead come and go as functions are called and return.
Q 25What is the name for the bug in which a C program keeps allocating storage but never releases it?
Memory leak
A memory leak can go unnoticed in a short-lived tool, because modern operating systems reclaim everything when a program exits. In software that runs for months, the loss keeps growing.
Q 26Which adjective describes a C pointer that still holds the address of memory that has already been released?
Dangling
A dangling pointer looks valid but refers to memory the program no longer owns. If the system has since handed that memory to something else, writing through it silently corrupts unrelated data.
Q 27Which error is raised when a C program tries to read or write memory it is not allowed to access?
Segmentation fault
A segmentation fault is raised by hardware memory protection, which alerts the operating system that a program has strayed outside its own space. The usual response is to end the program on the spot.
Q 28The gets function was removed from C in the 2011 standard because it made which security flaw unavoidable?
Buffer overflow
A buffer overflow was always possible because gets is never told how big its destination is. A long enough line of input simply keeps writing past the end.
Q 29Which C operator, usually written with a type name in parentheses, reports how many bytes that type occupies?
sizeof
The sizeof operator looks like a function call but is built into the language itself. Its result has the unsigned type size_t, the same type the allocation functions expect.
Q 30Which symbol is used in C both to declare a pointer and to reach the value it points to?
Asterisk
The asterisk does double duty: in a declaration it marks a variable as a pointer, and in an expression it dereferences one. C also uses the same symbol for multiplication.