Unlock hundreds more features
Save your Quiz to the Dashboard
View and Export Results
Use AI to Create Quizzes and Analyse Results

Sign inSign in with Facebook
Sign inSign in with Google

Take the Blind Coding C Quiz and Prove Your Skills

Think you can ace this C programming quiz? Dive into our blind coding challenge!

Difficulty: Moderate
2-5mins
Learning OutcomesCheat Sheet
Paper art quiz scene with C code sheets question marks pencil and memory modules on teal background.

This C blind coding quiz helps you practice writing code without hints and spot gaps in syntax, control flow, pointers, and memory use. Work through short, timed tasks to build speed and accuracy, then use the results to focus study before an exam or interview.

On most 64-bit systems, what is the size of an int in C?
4 bytes
16 bytes
8 bytes
2 bytes
On most modern 64-bit platforms following the LP64 model, an int is 4 bytes. This is defined by the implementation's ABI rather than the C standard. You can verify common sizes on popular ABIs. .
Which header file declares the printf function?
stdlib.h
math.h
stdio.h
string.h
The printf function is part of the standard input/output library in C, which is declared in stdio.h. Other headers serve different purposes. .
What is the correct signature for the entry point of a standard C program?
void main()
int main(void)
main():int
int start()
The ISO C standard defines main to return int and take either void or (int, char**). Using void main is undefined behavior. .
Which keyword is used to declare a constant in C?
constant
immutable
#define
const
The const keyword in C marks a variable as read-only after initialization. #define is a preprocessor directive and not a keyword. .
Which operator represents logical AND in C?
&&
&
||
AND
In C, && is the logical AND operator, evaluating to true if both operands are nonzero. & is the bitwise AND operator. .
How do you start a multi-line comment in C?
/*
//
#
Multi-line comments in C begin with /* and end with */. // is a single-line comment. .
What is the default initial value of a static variable in C if not explicitly initialized?
Garbage
Zero
Depends on compiler
Uninitialized
Static-duration objects are zero-initialized by default according to the C standard. This applies to static globals and local statics. .
What is the result of the expression 5 / 2 in C when both operands are integers?
Runtime error
2.5
3
2
Integer division in C discards the fractional part, so 5/2 evaluates to 2. No runtime error occurs. .
Which declaration correctly defines an array of 10 integers?
int arr[10];
int arr{10};
int arr=(10);
int arr<>10;
In C, arrays are declared using square brackets: int arr[10]. Other syntax is invalid. .
What is the value returned by sizeof(char) in C?
2
1
Undefined
0
The C standard defines sizeof(char) as 1 by definition. All other object sizes are measured in units of char. .
Which of the following correctly demonstrates pointer arithmetic?
p+1 shifts by 1 byte
p+1 decrements pointer
p+1 holds address of p[1] always
p+1 shifts by size of *p
When adding 1 to a pointer p, it advances by sizeof(*p) bytes. That reflects the object's type size. .
Which symbol ends every statement in C?
:
.
;
#
C statements are terminated with a semicolon. This is required except in certain compound statements. .
Where are global variables stored in memory on most systems?
Stack segment
Heap segment
Data/BSS segment
Code segment
Global/static variables reside in the data segment (initialized) or BSS (zero-initialized). The stack and heap are for local and dynamic data. .
How many times will this loop execute? for(int i=0;i<5;i++){}
5
6
4
Depends on compiler
The loop starts with i=0 and runs while i<5, executing for i=0,1,2,3,4, for a total of 5 iterations. .
What is the correct way to declare a pointer to a char?
char& ptr;
char *ptr;
pointer ptr;
char ptr;
In C, pointers are declared using an asterisk: char *ptr. Other syntaxes are invalid. .
What is the result of ++i versus i++ in an expression?
++i returns new value; i++ returns old value
Both increment then return old value
Undefined behavior
Both return new value
Pre-increment (++i) increases i then yields the new value, while post-increment (i++) yields the original value then increments. This is defined by C operator semantics. .
Which function is used to allocate dynamic memory in C?
alloc()
new()
reserve()
malloc()
malloc() allocates a specified number of bytes and returns a void pointer. new is C++ only. .
What must you do after calling malloc to avoid memory leaks?
Set pointer to NULL
Call free
Call delete
Nothing
In C, allocated memory from malloc() must be released with free() to avoid leaks. delete is C++. Setting pointer to NULL doesn't free memory. .
Which function correctly copies one C-string to another?
strmove(dest, src)
strcpy(dest, src)
memcopy(dest, src)
strncpy(dest, src)
strcpy(dest, src) copies the null-terminated string including the terminator. strncpy is similar but requires a size. .
How do you access a struct member in C through a pointer?
ptr**.member
ptr.member
ptr->member
(*ptr).member
The -> operator accesses a member through a pointer to a struct. It's shorthand for (*ptr).member. .
What happens when you pass an array to a function in C?
Array converted to struct
Function cannot accept arrays
Pointer to first element is passed
Entire array copied by value
In C, arrays decay to pointers when passed to functions, so only the address of the first element is passed. No full copy is made. .
Which function opens a file for reading in C?
file_open(filename)
fopen(filename, "r")
open("r", filename)
fopen(filename, "w")
fopen() with mode "r" opens a file for reading. Other modes change access type. .
What does NULL represent in C?
Pointer to stack
Undefined value
Uninitialized memory
Zero integer constant
NULL is a macro representing a null pointer constant, typically defined as ((void*)0). It is not an uninitialized or undefined value. .
Which operator compares for equality in C?
=
==
===
<>
The == operator tests equality between two values. A single = is assignment. === is invalid in C. .
What is a segmentation fault in C?
Logical error in code
Invalid memory access at runtime
Compile-time error
Successful program exit
A segmentation fault occurs when a program accesses memory it is not allowed to. It's a runtime error signaled by the OS. .
What is the scope of a static local variable in C?
Function scope with lifetime of program
Block scope with automatic lifetime
Global scope
File scope
A static local variable retains its value between calls and exists for the program's lifetime but remains visible only in its defining function. .
What is the underlying type of an enum if not specified?
int
unsigned
char
Depends on values
In C, the underlying type of an unqualified enum is compatible with int. Values must be representable as int. .
What does the restrict keyword indicate in C99?
Pointer is volatile
Pointer is the only reference to that object
Pointer cannot be NULL
Pointer is read-only
restrict tells the compiler that for the lifetime of the pointer, only it or a value directly derived from it will access the object, enabling optimization. .
Which function reads a line from stdin in C11?
fgets(buffer, size, stdin)
scanf("%s", buffer)
gets(buffer)
readline(buffer)
fgets reads up to size-1 characters and null-terminates. gets is removed due to safety issues. .
How do you declare a pointer to a pointer to int?
int p**;
pointer p;
int &*p;
int **p;
A pointer to pointer is declared as int **p. Each asterisk adds a level of indirection. .
What undefined behavior occurs when you call free() twice on the same pointer?
Double free error
Safe deallocation
Memory leak
Nothing happens
Calling free() on the same pointer twice leads to undefined behavior, often causing a crash or heap corruption. It must only be freed once. .
Which function safely moves memory blocks that may overlap?
move()
strncpy()
memmove()
memcpy()
memmove() correctly handles overlapping source and destination regions. memcpy() has undefined behavior on overlap. .
What is the purpose of the volatile qualifier in C?
Optimize variable aggressively
Prevent compiler optimizations on variable
Define compile-time constant
Make variable thread-safe
volatile tells the compiler that a variable may change at any time and prevents certain optimizations. Used for memory-mapped I/O or signal handlers. .
How is alignment of a type queried in C11?
sizeof(type)
_Alignof(type)
alignment(type)
alignof(type)
In C11, _Alignof(type) is the operator; alignof(type) is available via . It yields the alignment requirement. .
What happens if you shift a 1-bit left by the width of the type?
Compiler warning
Zero
Undefined behavior
One
Shifting by an amount greater or equal to the width of the type is undefined behavior in C. The standard forbids it. .
Which mechanism allows non-local jumps in C?
longjmp/setjmp
goto
signal()
throw/catch
setjmp saves the calling environment and longjmp restores it, enabling non-local jumps. goto is local. .
What is type punning via a union used for?
Safe memory sharing between types
Function overloading
Prevent aliasing
Compile-time casting
Unions allow accessing the same memory as different types, known as type punning. It can break strict aliasing rules but is common. .
Which function returns the length of a null-terminated string?
strlength(str)
count(str)
sizeof(str)
strlen(str)
strlen computes the number of characters before the null terminator in a C-string. sizeof yields the size of the pointer or array type. .
What is the difference between memcpy and memmove?
No difference
memcpy is slower
memmove handles overlap
memcpy handles overlap
memmove correctly handles overlapping source/destination, while memcpy does not. memmove may be slightly slower. .
What does the keyword restrict help the compiler optimize?
Function inlining
Loop unrolling
Memory alignment
Aliasing assumptions
restrict informs the compiler that pointers won't alias, allowing better optimizations. It doesn't affect alignment or inlining directly. .
Where are automatic variables typically allocated?
Data segment
Heap
BSS segment
Stack
Automatic (local) variables are allocated on the program stack by default. Heap is for dynamic allocation. .
What error does dereferencing a NULL pointer cause?
Automatically allocates memory
Returns zero
Compile-time error
Undefined behavior at runtime
Dereferencing NULL leads to undefined behavior, often a segmentation fault at runtime. The compiler cannot always detect it. .
How do you declare an array of function pointers returning int?
int (*arr[])()
int arr[](*)
int arr*[]()
(*int arr)[]()
int (*arr[])() declares arr as an array of pointers to functions returning int. Parentheses bind correctly around *arr. .
What is undefined about modifying a variable twice between sequence points?
Undefined behavior
Guaranteed order
Raises compile error
Only affects optimization
Modifying a variable more than once without an intervening sequence point yields undefined behavior. This rule prevents unpredictable results. .
Which preprocessor directive tests if a macro is defined?
#ifdef
#ifndef defined
#ifndef
#if defined
#ifdef checks if a macro is defined. #ifndef checks if not defined. Other forms are invalid. .
What feature does GCC's __attribute__((aligned)) provide?
Align function calls
Optimize loop alignment
Enforce variable alignment in memory
Custom heap alignment
__attribute__((aligned)) sets a minimum alignment for variables or struct fields. It influences memory layout. .
In which segment does dynamically loaded code reside?
BSS segment
Heap segment
Stack segment
Text segment
Loaded shared libraries and dynamic code are placed in the text segment (executable code). Heap and stack are for data. .
What does inline assembly with asm volatile do?
Marks assembly as deprecated
Enables vectorization
Guarantees atomic execution
Prevents compiler from reordering around asm
asm volatile tells the compiler not to optimize or reorder the inline assembly with surrounding code. This is crucial for hardware access. .
0
{"name":"On most 64-bit systems, what is the size of an int in C?", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"On most 64-bit systems, what is the size of an int in C?, Which header file declares the printf function?, What is the correct signature for the entry point of a standard C program?","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}

Study Outcomes

  1. Write Code Without Prompts -

    Through blind coding challenges, you'll practice writing C code from memory, strengthening recall of key language constructs.

  2. Identify and Fix Syntax Errors -

    You'll learn to spot common C syntax mistakes under time pressure, improving your ability to debug code quickly.

  3. Implement Control Structures -

    You'll apply loops and conditional statements in a blind coding format, enhancing your mastery of control flow in C.

  4. Manage Memory with Pointers -

    You'll tackle pointer arithmetic and dynamic allocation tasks to reinforce best practices in memory management.

  5. Enhance Problem-Solving Speed -

    By working through fast-paced quiz questions, you'll accelerate your ability to devise efficient C solutions under constraints.

  6. Assess Your C Proficiency -

    Upon completion, you'll review performance metrics to identify strengths and pinpoint areas for further study.

Cheat Sheet

  1. Mastering C Syntax Essentials -

    Review data types, function prototypes, and header inclusion rules as defined by the ISO C standard (ISO/IEC 9899). Remember the K&R mnemonic "Type Name(Parameter List){…}" to recall proper function syntax. This foundation is crucial for any blind coding C challenge or C syntax test.

  2. Pointer and Memory Management Quiz Prep -

    Understand dynamic allocation via malloc/free and the importance of initializing pointers to prevent undefined behavior (per Stanford CS107). A handy trick is "Allocate, Use, Free" in that order to avoid leaks. These concepts are at the heart of any memory management quiz segment in a blind coding exercise.

  3. Efficient Control Structures -

    Practice if-else, switch-case, for, and while loops by tracing code on paper before typing to simulate blind coding conditions (source: Carnegie Mellon 15-111). Use the mnemonic "Loop, Control, Exit" as a mental checklist when running a control structures quiz. Mastery here speeds up writing logic without compiler feedback.

  4. Arrays and String Handling -

    Differentiate between char arrays and char pointers, keeping null-termination in mind (per The C Programming Language by Kernighan & Ritchie). A simple mnemonic "\0 marks the end, so index +1 for length" helps avoid buffer overruns. This knowledge shines in C programming quiz string puzzles.

  5. Debugging and Best Practices -

    In blind coding environments, anticipate common pitfalls by checking return values and using assertions (as recommended by the GNU and Linux Documentation Project). Employ a systematic "Check, Debug, Refine" approach and mentally simulate Valgrind error detection if actual tools aren't available. This strategy boosts confidence in any C programming quiz scenario.

Powered by: Quiz Maker