Sign Up Sign Up


Have an account? Sign In Now

Sign In Sign In


Forgot Password?

Don't have account, Sign Up Here

Forgot Password Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.


Have an account? Sign In Now

You must login to ask a question.


Forgot Password?

Need An Account, Sign Up Here

You must login to add post.


Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

RTSALL Logo RTSALL Logo
Sign InSign Up

RTSALL

RTSALL Navigation

  • Home
  • Tutorials
    • All Subjects & Branches (90+)
    • C Programming MCQs
    • Python Programming MCQs
    • Data Structures MCQs
    • DBMS & SQL MCQs
    • Computer Networks MCQs
    • Operating Systems MCQs
    • Quantitative Aptitude MCQs
  • Interview
    • Interview Preparation Portal
    • Web API & REST API
    • SQL Server
    • System Design
    • C# (.NET 8/9)
    • ASP.NET MVC & Core
    • DSA (Data Structures)
    • Cyber Security
    • Burp Suite (AppSec)
  • Tools
    • Run Code
    • JSON Beautifier
    • Regex Tester
    • Diff Checker
    • JWT Decoder
    • UUID Generator
    • .htaccess Generator
    • YAML/JSON Converter
    • SQL Formatter
    • Cron Generator
    • JSON to CSV/Excel
    • System Design Estimator
    • Chmod Calculator
    • Duplicate Line Remover
  • DSA
    • All DSA Problems
    • Online C++ Runner
    • Arrays, Strings & Cache
    • Two Pointers & Sliding Window
    • Linked Lists & Custom Allocators
    • Stacks, Queues & Ring Buffers
    • Trees, BSTs & Indexes
    • Tries & Prefix Search
    • Heaps & Priority Schedulers
    • Hashing & Collision Resolution
    • Graphs & Network Topologies
    • Dynamic Programming
    • Advanced Bitmask & Tree DP
    • Greedy & Resource Allocation
    • Binary Search & State Spaces
    • Bit Manipulation & Low-Level
    • System-Scale & Probabilistic
  • AI Utilities
    • Token Counter
    • JSON Schema Compiler
    • Fine-Tuning JSONL Converter
    • Vector RAG Playground
    • Prompt Optimizer & Architect
    • LLM GPU VRAM Calculator
    • .NET AI Roadmap
  • Finance Tools
    • Compound Interest Calculator
    • SIP Calculator
    • Simple Interest Calculator
    • EMI Calculator
    • Present Value (PV) Calculator
    • Compound Interest Calculator
    • Future Value (FV) Calculator
    • NPV Calculator
    • IRR Calculator
    • CAGR Calculator
    • Dividend Income Calculator
    • Yield on Cost Calculator
    • Dividend Payout Ratio
    • WACC Calculator
    • CAPM & Cost of Equity
    • Cost of Debt Calculator
    • DCF Valuation Calculator
    • Enterprise Value Calculator
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Tutorials
    • All Subjects & Branches (90+)
    • C Programming MCQs
    • Python Programming MCQs
    • Data Structures MCQs
    • DBMS & SQL MCQs
    • Computer Networks MCQs
    • Operating Systems MCQs
    • Quantitative Aptitude MCQs
  • Interview
    • Interview Preparation Portal
    • Web API & REST API
    • SQL Server
    • System Design
    • C# (.NET 8/9)
    • ASP.NET MVC & Core
    • DSA (Data Structures)
    • Cyber Security
    • Burp Suite (AppSec)
  • Tools
    • Run Code
    • JSON Beautifier
    • Regex Tester
    • Diff Checker
    • JWT Decoder
    • UUID Generator
    • .htaccess Generator
    • YAML/JSON Converter
    • SQL Formatter
    • Cron Generator
    • JSON to CSV/Excel
    • System Design Estimator
    • Chmod Calculator
    • Duplicate Line Remover
  • DSA
    • All DSA Problems
    • Online C++ Runner
    • Arrays, Strings & Cache
    • Two Pointers & Sliding Window
    • Linked Lists & Custom Allocators
    • Stacks, Queues & Ring Buffers
    • Trees, BSTs & Indexes
    • Tries & Prefix Search
    • Heaps & Priority Schedulers
    • Hashing & Collision Resolution
    • Graphs & Network Topologies
    • Dynamic Programming
    • Advanced Bitmask & Tree DP
    • Greedy & Resource Allocation
    • Binary Search & State Spaces
    • Bit Manipulation & Low-Level
    • System-Scale & Probabilistic
  • AI Utilities
    • Token Counter
    • JSON Schema Compiler
    • Fine-Tuning JSONL Converter
    • Vector RAG Playground
    • Prompt Optimizer & Architect
    • LLM GPU VRAM Calculator
    • .NET AI Roadmap
  • Finance Tools
    • Compound Interest Calculator
    • SIP Calculator
    • Simple Interest Calculator
    • EMI Calculator
    • Present Value (PV) Calculator
    • Compound Interest Calculator
    • Future Value (FV) Calculator
    • NPV Calculator
    • IRR Calculator
    • CAGR Calculator
    • Dividend Income Calculator
    • Yield on Cost Calculator
    • Dividend Payout Ratio
    • WACC Calculator
    • CAPM & Cost of Equity
    • Cost of Debt Calculator
    • DCF Valuation Calculator
    • Enterprise Value Calculator
  • About Us
  • Blog
  • Contact Us
Home/RTSALL Educational Academy: Subject MCQs, Practice Tests & Detailed Explanations/C Programming: 5-Chapter Comprehensive Practice & 75 Verified MCQs

C Programming: 5-Chapter Comprehensive Practice & 75 Verified MCQs

Home / Learning Platform / Programming Languages / C Programming MCQs
Programming Languages 🟢 75 Verified MCQs • 5 Complete Chapters Active ⭐ Interview & Exam Grade

C Programming: 5-Chapter Comprehensive Practice & 75 Verified MCQs

Master C Programming with our complete 5-chapter question bank. Each verified MCQ provides four distinct options, verified solution keys, step-by-step technical rationale, and high-yield conceptual rules.

Curriculum Roadmap & Chapters Covered (All Live & Unlocked):
✓ Chapter 1: Operators, Expressions & Precedence (Q1 – Q15)
✓ Chapter 2: Pointers, Arithmetic & Memory Allocation (Q16 – Q30)
✓ Chapter 3: Functions, Storage Classes & Recursion (Q31 – Q45)
✓ Chapter 4: Control Structures, Loops & Logic (Q46 – Q60)
✓ Chapter 5: Arrays, Strings, Structs & File I/O (Q61 – Q75)
📝 Total Questions: 75 Verified MCQs
📚 Modules: 5 Complete Chapters
⏱️ Est. Practice Time: ~90 minutes
🎯 Target Benchmark: 80% (60/75 Correct)
Select Chapter to Practice:
Interactive Practice Dashboard
Answered: 0 / 75 Correct: 0 Accuracy: 0% Streak: 🔥 0
Currently Displaying: All 75 Questions across Chapters 1 to 5. Click any option for instant evaluation and in-depth explanations.
Curriculum Track • Module 1 of 5
Chapter 1: Operators, Expressions & Precedence (Q1 – Q15)
Question 1 of 75 Chapter 1
Which operator in C is used to dereference a pointer variable and access the value residing at the pointed memory address?
A. & (Address-of operator)
B. * (Indirection / Dereference operator)
C. -> (Structure pointer member operator)
D. % (Modulo operator)
✔ Correct Answer: Option B
Detailed Explanation: The asterisk (*) acts as the indirection (dereference) operator when applied to an existing pointer. It reads or writes the value located at the memory address stored in the pointer variable. In contrast, ‘&’ retrieves the memory address of an lvalue.
🎯 Key Learning Point: Pointer definition ‘int *p;’ declares a pointer, whereas ‘*p = 20;’ dereferences that pointer to write to the target memory.
Question 2 of 75 Chapter 1
What will be the printed output of the following C code snippet?

int x = 5;
int y = ++x * 2;
printf("%d %d", x, y);
int x = 5;
int y = ++x * 2;
printf("%d %d", x, y);
A. 5 10
B. 6 10
C. 6 12
D. 5 12
✔ Correct Answer: Option C
Detailed Explanation: The pre-increment operator ‘++x’ increments the value of x from 5 to 6 before its value is evaluated in the multiplication expression. Consequently, y evaluates to 6 * 2 = 12, leaving x as 6 and y as 12.
🎯 Key Learning Point: Pre-increment (++x) modifies the operand prior to value evaluation; post-increment (x++) evaluates the operand first and increments afterwards.
Question 3 of 75 Chapter 1
Which bitwise expression in C isolates and checks whether the 3rd bit (0-indexed from right) of an integer variable 'flags' is set to 1?
A. flags & (1 << 3)
B. flags | (1 << 3)
C. flags ^ (1 << 3)
D. flags >> 3
✔ Correct Answer: Option A
Detailed Explanation: Shifting 1 to the left by 3 positions (‘1 << 3') generates the binary mask '00001000' (decimal 8). Performing a bitwise AND ('flags & 8') results in a non-zero value if the 3rd bit is set, and 0 if it is clear.
🎯 Key Learning Point: Bitwise AND (&) combined with bitshifts (<<) is standard in low-level systems programming for testing specific hardware status bits.
Question 4 of 75 Chapter 1
How does the logical AND operator (&&) behave in C when the left-hand operand evaluates to false (0)?
A. Both operands are evaluated and an error is flagged.
B. The right-hand operand is skipped entirely due to short-circuit evaluation.
C. The right-hand operand is evaluated first, then the left.
D. The program terminates with a SIGSEGV fault.
✔ Correct Answer: Option B
Detailed Explanation: C guarantees short-circuit evaluation for logical operators. For ‘A && B’, if ‘A’ is false (0), the entire logical expression cannot possibly be true; thus, ‘B’ is never evaluated, preventing potential side effects or null-pointer dereferences in the second clause.
🎯 Key Learning Point: Short-circuiting allows safe constructs like ‘if (ptr != NULL && *ptr == 10)’ without crashing on null references.
Question 5 of 75 Chapter 1
What is the return value and behavior of the sizeof operator in C when evaluated on an array vs a decayed pointer?
int arr[10];
int *ptr = arr;
printf("%zu %zu", sizeof(arr), sizeof(ptr));
A. It returns 10 * sizeof(int) for arr, and the machine architecture pointer width (e.g., 4 or 8 bytes) for ptr.
B. It returns 10 for both arr and ptr.
C. It returns 40 for both arr and ptr regardless of architecture.
D. It generates a compiler error because arrays cannot be passed to sizeof.
✔ Correct Answer: Option A
Detailed Explanation: ‘sizeof(arr)’ evaluates the total byte size of the allocated contiguous block (10 elements * 4 bytes = 40 bytes on typical 32/64-bit systems). However, when assigned to ‘ptr’, array decay occurs, and ‘sizeof(ptr)’ only measures the pointer memory size (8 bytes on 64-bit platforms).
🎯 Key Learning Point: ‘sizeof’ is an operator, not a runtime function; for non-VLA types, its result is computed strictly at compile-time.
Question 6 of 75 Chapter 1
According to the C99 and C11 standards, what is the result of the modulo operation (-14 % 3)?
A. 1
B. -2
C. 2
D. Undefined behavior
✔ Correct Answer: Option B
Detailed Explanation: C99/C11 defines that integer division truncates toward zero: (-14 / 3) = -4. Because C enforces (a / b) * b + (a % b) == a, we have (-4 * 3) + remainder = -14 => -12 + remainder = -14, yielding remainder = -2. The sign of (a % b) strictly matches the sign of the dividend (a).
🎯 Key Learning Point: In modern C (C99+), the sign of the modulo operator’s result always matches the dividend: (-a % b) produces a negative or zero result.
Question 7 of 75 Chapter 1
What will be printed by the following code that utilizes the comma operator?

int a = (1, 2, 3) + (4, 5);
printf("%d", a);
int a = (1, 2, 3) + (4, 5);
printf("%d", a);
A. 6
B. 8
C. 15
D. 7
✔ Correct Answer: Option B
Detailed Explanation: The comma operator evaluates each sub-expression from left to right and yields the value of the rightmost sub-expression. Thus, ‘(1, 2, 3)’ evaluates to 3, and ‘(4, 5)’ evaluates to 5. Adding them together gives 3 + 5 = 8.
🎯 Key Learning Point: The comma operator has the lowest precedence of all C operators and introduces a sequence point between its left and right expressions.
Question 8 of 75 Chapter 1
What is the primary difference between the bitwise NOT operator (~) and the logical NOT operator (!) in C?
A. '~' operates on every bit (1s complement), while '!' converts non-zero to 0 and 0 to 1.
B. '~' is only for unsigned integers; '!' is only for signed floats.
C. There is no functional difference; they are aliases.
D. '!' produces a 32-bit bitmask; '~' produces a boolean 0 or 1.
✔ Correct Answer: Option A
Detailed Explanation: The bitwise NOT operator ‘~’ inverts every individual bit of its operand (0 becomes 1 and 1 becomes 0, producing the one’s complement). The logical NOT operator ‘!’ performs a truth-table inversion: it returns 1 if the operand is 0, and 0 if the operand is any non-zero value.
🎯 Key Learning Point: If x = 0; then ~x = ~0x00000000 = 0xFFFFFFFF (-1 in two’s complement), while !x = 1.
Question 9 of 75 Chapter 1
What does the expression 'ptr++' do when ptr is a pointer of type 'int *' on a 64-bit architecture where sizeof(int) is 4 bytes?
A. Increments the numerical memory address in ptr by 1 byte.
B. Increments the numerical memory address in ptr by 4 bytes (sizeof(int)).
C. Increments the value pointed to by ptr by 1.
D. Increments the numerical memory address in ptr by 8 bytes.
✔ Correct Answer: Option B
Detailed Explanation: Pointer arithmetic in C is scaled by the size of the referenced type. Incrementing ‘ptr++’ advances the address by 1 unit of ‘int’, which is 4 bytes. It points to the next sequential integer in contiguous memory.
🎯 Key Learning Point: For any pointer ‘T *p’, the expression ‘p + n’ evaluates to address: ((uintptr_t)p + n * sizeof(T)).
Question 10 of 75 Chapter 1
Which of the following operators cannot be used with floating-point operands (float, double) in C?
A. / (Division operator)
B. % (Modulo remainder operator)
C. ?: (Ternary conditional operator)
D. == (Equality operator)
✔ Correct Answer: Option B
Detailed Explanation: The ‘%’ (modulo) operator requires both operands to be of integer types (such as char, int, long). Using ‘%’ on floating-point numbers triggers a compile-time error. For floating-point remainder, the standard library function ‘fmod()’ from must be used.
🎯 Key Learning Point: Use fmod(x, y) from for floating point remainders; the % operator strictly demands integral operands.
Question 11 of 75 Chapter 1
In the expression 'int res = a > b ? a : b;', what is the operator category and arity of '?:'?
A. Binary relational operator
B. Ternary conditional operator
C. Unary conditional operator
D. Primary member selection operator
✔ Correct Answer: Option B
Detailed Explanation: The ‘?:’ operator is the only ternary operator in C because it requires exactly three operands: a condition, an expression evaluated if the condition is true (non-zero), and an expression evaluated if false (zero).
🎯 Key Learning Point: The conditional operator forms an expression, returning a value; unlike an ‘if-else’ statement which is a control flow structure.
Question 12 of 75 Chapter 1
What will be the output of the following C code snippet?

int x = 10, y = 20, z = 30;
int r = x < y < z;
printf("%d", r);
int x = 10, y = 20, z = 30;
int r = x < y < z;
printf("%d", r);
A. 1
B. 0
C. 30
D. Compiler Error
✔ Correct Answer: Option A
Detailed Explanation: Relational operators have left-to-right associativity. First, ‘x < y' (10 < 20) evaluates to true (1). Next, the expression becomes '1 < z' (1 < 30), which also evaluates to true (1). Therefore, r is assigned 1.
🎯 Key Learning Point: Relational chaining like ‘x < y < z' does not check if y is between x and z in C. To check mathematical ranges, explicit conjunction 'x < y && y < z' must be written.
Question 13 of 75 Chapter 1
What is the order of evaluation between prefix increment and pointer dereference in the expression '*++ptr'?
A. ptr is dereferenced first, then the pointed value is incremented.
B. ptr is incremented first, and then the newly pointed-to memory address is dereferenced.
C. Both occur simultaneously via compiler vectorization.
D. Triggers an undefined sequence point error in C11.
✔ Correct Answer: Option B
Detailed Explanation: Prefix increment ‘++’ and dereference ‘*’ share the same precedence level and associate from right to left. Because ‘++’ is adjacent to ‘ptr’ on the right, ‘++ptr’ evaluates first (advancing the pointer), and then ‘*’ dereferences the updated address.
🎯 Key Learning Point: Contrast ‘*++ptr’ (advances pointer, then dereferences) with ‘++*ptr’ (dereferences address, then increments the value stored there).
Question 14 of 75 Chapter 1
Which bitwise operation clears (sets to 0) the least significant set bit (rightmost 1) of an unsigned integer 'n' in O(1) time?
A. n & (n – 1)
B. n | (n + 1)
C. n ^ (n – 1)
D. n & ~n
✔ Correct Answer: Option A
Detailed Explanation: Subtracting 1 from n flips all bits starting from the rightmost set bit up to the least significant bit. When performing bitwise AND with the original n (‘n & (n – 1)’), the rightmost 1-bit becomes 0 while all higher-order bits remain unaffected. This is known as Brian Kernighan’s bit algorithm.
🎯 Key Learning Point: Brian Kernighan’s algorithm uses ‘n = n & (n – 1)’ repeatedly to count set bits in O(set bits) time rather than O(total bits).
Question 15 of 75 Chapter 1
What will be printed when executing the following C code?

int a = 1;
if (a = 0)
printf("True\n");
else
printf("False\n");
int a = 1;
if (a = 0)
    printf("True\n");
else
    printf("False\n");
A. True
B. False
C. Compilation Error
D. Runtime Exception
✔ Correct Answer: Option B
Detailed Explanation: The condition contains an assignment operator ‘=’ rather than an equality operator ‘==’. The expression ‘a = 0’ assigns 0 to variable ‘a’ and evaluates to the assigned value, which is 0 (false in C). Therefore, the ‘else’ branch executes, printing ‘False’.
🎯 Key Learning Point: Use compiler warning flags like ‘-Wall -Wextra’ (or place constants on the left: ‘if (0 == a)’) to catch accidental assignments inside conditional checks.
Curriculum Track • Module 2 of 5
Chapter 2: Pointers, Arithmetic & Memory Allocation (Q16 – Q30)
Question 16 of 75 Chapter 2
What is the return type of the malloc() function in C when memory is successfully allocated?
A. int *
B. void *
C. char *
D. size_t *
✔ Correct Answer: Option B
Detailed Explanation: malloc() returns a generic pointer of type ‘void *’ pointing to the beginning of the newly allocated contiguous byte block. Because void* implicitly converts to any data pointer type in C, explicit casting is not required.
🎯 Key Learning Point: In standard C (unlike C++), casting the return value of malloc (e.g. ‘int *p = (int*)malloc(…)’) is redundant and can mask failure to include .
Question 17 of 75 Chapter 2
What happens if free(ptr) is called on a pointer variable that holds the value NULL?
A. Triggers a segmentation fault at runtime.
B. No operation is performed and the function returns cleanly without error.
C. Compiles with a fatal syntax warning.
D. Frees the entire heap segment.
✔ Correct Answer: Option B
Detailed Explanation: According to the ISO C standard (C99/C11 §7.22.3.4), if the argument passed to free() is a null pointer, no action is taken. It is completely safe and well-defined behavior.
🎯 Key Learning Point: You do not need to wrap free() calls in ‘if (ptr != NULL)’; free(ptr) handles NULL natively.
Question 18 of 75 Chapter 2
What is a 'Dangling Pointer' in C?
A. A pointer initialized to address 0x00000000.
B. A pointer that points to a memory location that has already been deallocated or freed.
C. A pointer that has not yet been declared in scope.
D. A pointer that references read-only code segments.
✔ Correct Answer: Option B
Detailed Explanation: A dangling pointer arises when the memory block pointed to is released (via free() or stack frame pop) but the pointer variable still holds the deallocated address. Dereferencing a dangling pointer triggers undefined behavior.
🎯 Key Learning Point: Best practice: Immediately assign ‘ptr = NULL;’ after calling ‘free(ptr)’ to prevent accidental reuse.
Question 19 of 75 Chapter 2
How does calloc(n, size) differ functionally from malloc(n * size)?
A. calloc allocates memory from the stack; malloc allocates from the heap.
B. calloc zeroes out all allocated memory bytes to 0; malloc leaves memory uninitialized with indeterminate garbage values.
C. calloc cannot allocate more than 1024 bytes.
D. calloc operates twice as fast as malloc on ARM processors.
✔ Correct Answer: Option B
Detailed Explanation: calloc() allocates memory for an array of n elements of specified size and explicitly initializes all bits in the allocated block to zero. malloc() merely locates an available block and leaves existing residual memory contents untouched.
🎯 Key Learning Point: calloc also checks for integer overflow during the multiplication (n * size), failing safely if the requested total exceeds size_t.
Question 20 of 75 Chapter 2
What will be printed when executing the following pointer arithmetic snippet on a 32-bit architecture where sizeof(int) is 4 bytes?

int arr[5] = {10, 20, 30, 40, 50};
int *p = arr;
printf("%d", *(p + 3));
int arr[5] = {10, 20, 30, 40, 50};
int *p = arr;
printf("%d", *(p + 3));
A. 10
B. 30
C. 40
D. 50
✔ Correct Answer: Option C
Detailed Explanation: The expression ‘p + 3’ advances the pointer address by 3 * sizeof(int) bytes, targeting index 3 of the array. Dereferencing *(p + 3) yields arr[3], which is 40.
🎯 Key Learning Point: Array subscript notation ‘arr[i]’ is syntactic sugar for ‘*(arr + i)’, which is also mathematically identical to ‘*(i + arr)’ or ‘i[arr]’.
Question 21 of 75 Chapter 2
What is the difference between 'const int *p' and 'int * const p' in C declarations?
A. 'const int *p' is a pointer to a constant integer (value cannot change); 'int * const p' is a constant pointer (address cannot change).
B. 'const int *p' allocates memory in ROM; 'int * const p' allocates in RAM.
C. There is no difference; const placement is purely stylistic.
D. 'int * const p' converts the pointer to an array.
✔ Correct Answer: Option A
Detailed Explanation: Read declarations from right to left: ‘const int *p’ means p is a pointer to an integer that is constant (*p cannot be modified). ‘int * const p’ means p is a const pointer to an integer (the address in p is locked and cannot point elsewhere, but *p can be modified).
🎯 Key Learning Point: Use the clock-wise/spiral rule: ‘const’ modifies whatever identifier or asterisk appears immediately to its left (or right if nothing is to the left).
Question 22 of 75 Chapter 2
What does realloc(ptr, new_size) do if there is insufficient contiguous space at the current memory block to expand?
A. It throws an OutOfMemory exception and terminates the application.
B. It allocates a brand new memory block of new_size elsewhere, copies the existing data payload to the new location, frees the old block, and returns the new pointer.
C. It truncates the data and keeps the original address.
D. It pauses CPU execution until memory becomes available.
✔ Correct Answer: Option B
Detailed Explanation: If in-place expansion is impossible, realloc() allocates a new chunk of heap memory of size ‘new_size’, copies the contents from the old buffer up to the minimum of the old and new sizes, releases the old buffer via free(), and returns a pointer to the new memory block.
🎯 Key Learning Point: Always store realloc’s return value in a temporary pointer: ‘void *tmp = realloc(p, sz); if (tmp) p = tmp;’ to prevent memory leaks if realloc returns NULL on allocation failure.
Question 23 of 75 Chapter 2
What is the result of subtracting two pointers pointing to elements in the same array: (ptr2 – ptr1)?
int arr[10];
int *ptr1 = &arr[2];
int *ptr2 = &arr[7];
printf("%td", ptr2 - ptr1);
A. The number of bytes between the two addresses (20 bytes).
B. The number of elements between the two pointers (5 of type ptrdiff_t).
C. The sum of the two memory addresses.
D. Undefined behavior.
✔ Correct Answer: Option B
Detailed Explanation: Pointer subtraction in C computes the number of elements of the referenced type between the two addresses: (Address2 – Address1) / sizeof(T). Here, 7 – 2 = 5 elements. The result has standard signed type ‘ptrdiff_t’ from .
🎯 Key Learning Point: Pointer subtraction is strictly defined only when both pointers point to elements of the same array object (or one past the end).
Question 24 of 75 Chapter 2
What is a 'Memory Leak' in C?
A. Memory registers leaking electricity on the motherboard.
B. Dynamically allocated heap memory that is no longer referenced by any pointer and was never deallocated using free(), leaving it unusable.
C. A pointer reading memory outside stack limits.
D. Overwriting the null-terminator of a string.
✔ Correct Answer: Option B
Detailed Explanation: A memory leak occurs when a program allocates memory on the heap (via malloc, calloc, or realloc) but loses all pointers referencing that block without calling free(). Over time, repeated leaks consume available system RAM, causing performance degradation or crashes.
🎯 Key Learning Point: Use tools like Valgrind or AddressSanitizer (-fsanitize=address) during testing to detect memory leaks and invalid accesses.
Question 25 of 75 Chapter 2
What is the output of the following pointer dereferencing code?

int x = 100;
int *p = &x;
int **pp = &p;
printf("%d", **pp);
int x = 100;
int *p = &x;
int **pp = &p;
printf("%d", **pp);
A. Address of x
B. Address of p
C. 100
D. Compilation Error
✔ Correct Answer: Option C
Detailed Explanation: ‘p’ holds the address of x. ‘pp’ is a pointer-to-a-pointer holding the address of p. The first dereference ‘*pp’ resolves to ‘p’ (the address of x). The second dereference ‘**pp’ resolves to the value of x itself, which is 100.
🎯 Key Learning Point: Double pointers (T**) are frequently used in C to modify pointer arguments passed into functions (e.g. dynamic list node insertion).
Question 26 of 75 Chapter 2
What is a 'Wild Pointer' in C?
A. A pointer that points to another pointer.
B. An uninitialized pointer variable that contains an arbitrary, unpredictable garbage memory address.
C. A pointer declared inside a recursive function.
D. A pointer declared as volatile.
✔ Correct Answer: Option B
Detailed Explanation: A wild pointer is a pointer variable declared without explicit initialization (e.g., ‘int *p;’). It points to an arbitrary memory address determined by whatever random bits existed in that stack memory frame, making any dereference hazardous.
🎯 Key Learning Point: Always initialize pointers upon declaration: either to a valid object address or to ‘NULL’.
Question 27 of 75 Chapter 2
Can you perform direct arithmetic (e.g. ptr++) on a pointer declared as 'void *' according to standard ANSI C?
void *ptr = malloc(100);
ptr++;
A. Yes, it advances by 4 bytes.
B. No, standard C forbids arithmetic on void* because the size of an incomplete type (void) is undefined.
C. Yes, it advances by 8 bytes on 64-bit systems.
D. Yes, it automatically casts to char*.
✔ Correct Answer: Option B
Detailed Explanation: Because ‘void’ represents an incomplete type with no defined size, the ISO C standard strictly disallows pointer arithmetic on void*. (Note: GCC supports pointer arithmetic on void* as a non-standard compiler extension treating sizeof(void) as 1, but it is illegal in strict ISO C).
🎯 Key Learning Point: Cast void* to char* or uint8_t* before performing byte-level pointer arithmetic for ISO C compliance.
Question 28 of 75 Chapter 2
What does the declaration 'int (*fp)(int, int);' declare in C?
A. A function returning an array of two pointers to integers.
B. A function pointer named 'fp' that points to a function taking two int arguments and returning an int.
C. An array of function calls.
D. A pointer to an integer that takes two arguments.
✔ Correct Answer: Option B
Detailed Explanation: The parentheses around ‘(*fp)’ bind the asterisk to the identifier ‘fp’, establishing that fp is a pointer. The following ‘(int, int)’ specifies the function parameter list, and the leading ‘int’ specifies the function’s return type.
🎯 Key Learning Point: Function pointers enable callback architectures and dynamic dispatch tables in C (e.g., the comparison callback in qsort()).
Question 29 of 75 Chapter 2
What will occur if a program attempts to write data to a string literal through a pointer: 'char *str = "Hello"; str[0] = 'M';'?
char *str = "Hello";
str[0] = 'M';
A. The string becomes "Mello" successfully.
B. Undefined behavior, typically resulting in a segmentation fault or bus error.
C. The compiler replaces all occurrences of "Hello" in the binary.
D. Memory is dynamically duplicated on the heap.
✔ Correct Answer: Option B
Detailed Explanation: In C, string literals like “Hello” are placed in read-only data segments (.rodata). Attempting to modify read-only memory through a char* pointer causes a hardware write-protection fault (SIGSEGV).
🎯 Key Learning Point: To create a mutable string on the stack, declare an array: ‘char str[] = “Hello”; str[0] = ‘M’;’.
Question 30 of 75 Chapter 2
What is the purpose of the 'alloca()' function in environments where it is supported?
A. Allocates memory in persistent non-volatile flash storage.
B. Allocates temporary memory on the runtime stack frame, which is automatically deallocated when the enclosing function returns.
C. Allocates memory shared across multiple CPU cores.
D. Allocates memory only for file descriptors.
✔ Correct Answer: Option B
Detailed Explanation: ‘alloca()’ allocates memory on the stack rather than the heap. Memory allocated with alloca() is automatically released when the calling function exits (when the stack pointer is restored), eliminating the need for free().
🎯 Key Learning Point: Beware: alloca() can trigger stack overflow crashes on large allocations without returning a NULL pointer check.
Curriculum Track • Module 3 of 5
Chapter 3: Functions, Storage Classes & Recursion (Q31 – Q45)
Question 31 of 75 Chapter 3
What is the lifetime and scope of a local variable declared with the 'static' storage class specifier inside a function?
void counter() {
    static int count = 0;
    count++;
    printf("%d ", count);
}
A. Lifetime is function execution; Scope is global.
B. Lifetime is the entire program execution; Scope is local strictly to the function.
C. Lifetime is 1 second; Scope is block.
D. Lifetime is thread-specific; Scope is file.
✔ Correct Answer: Option B
Detailed Explanation: A static local variable is initialized exactly once (before program startup) and retains its value between successive calls for the entire lifespan of the program. However, its visibility (scope) remains strictly restricted to the block or function where it is declared.
🎯 Key Learning Point: Static local variables reside in the .data / .bss segment rather than on the transient function call stack.
Question 32 of 75 Chapter 3
What does declaring a global variable or function with the 'static' keyword at file scope achieve?
static int global_config = 42;
A. It makes the variable constant and read-only.
B. It restricts the linkage to internal linkage, making the symbol invisible to other translation units (object files) during the linking phase.
C. It moves the variable into CPU registers.
D. It prevents the variable from being initialized.
✔ Correct Answer: Option B
Detailed Explanation: At file scope, ‘static’ gives a variable or function internal linkage. This encapsulates the symbol within its current source (.c) file, preventing name collisions with identical symbols in other translation units.
🎯 Key Learning Point: Internal linkage (‘static’) is C’s foundational mechanism for implementing modular encapsulation and information hiding.
Question 33 of 75 Chapter 3
What is the default storage class of local variables declared inside a C function if no storage specifier is provided?
A. static
B. extern
C. auto
D. register
✔ Correct Answer: Option C
Detailed Explanation: Local variables declared inside a block or function have the ‘auto’ (automatic) storage class by default. Their storage is allocated on the call stack upon block entry and deallocated upon block exit.
🎯 Key Learning Point: The ‘auto’ keyword in C indicates automatic storage duration, unlike C++11 where ‘auto’ denotes type deduction.
Question 34 of 75 Chapter 3
What purpose does the 'extern' storage class specifier serve in a C program?
extern int system_state;
A. It allocates a new memory buffer on the heap.
B. It declares a variable or function without defining it, notifying the compiler that its definition and storage reside in another translation unit or elsewhere.
C. It converts local variables into thread-local variables.
D. It deletes the symbol from the object file.
✔ Correct Answer: Option B
Detailed Explanation: ‘extern’ creates a declaration rather than a definition. It tells the compiler that the variable exists and has external linkage, instructing the linker to resolve its memory address across linked compilation modules.
🎯 Key Learning Point: Declaration announces the type and name; Definition actually allocates storage for the object.
Question 35 of 75 Chapter 3
What will occur if a recursive function in C lacks a proper base case or terminates too deeply?
A. Heap memory fragmentation.
B. Stack overflow due to exhaustion of allocated call stack memory frames.
C. The compiler automatically loops back to main().
D. The program converts to multi-threading.
✔ Correct Answer: Option B
Detailed Explanation: Every recursive call allocates a stack frame storing arguments, return addresses, and local variables. Without a terminating base case, recursion proceeds until the stack exceeds its OS boundary limit, triggering a stack overflow (SIGSEGV).
🎯 Key Learning Point: Always verify that every recursive branch eventually converges toward a valid non-recursive base case.
Question 36 of 75 Chapter 3
What is 'Tail Recursion', and why is it significant for optimizing compilers?
int fact(int n, int acc) {
    if (n <= 1) return acc;
    return fact(n - 1, n * acc); // tail call
}
A. Recursion that begins at the end of an array.
B. When the recursive call is the final operation executed in the function, allowing compilers to reuse the current stack frame (Tail Call Optimization) avoiding stack growth.
C. Recursion that uses two base cases.
D. Recursion executing inside a while loop.
✔ Correct Answer: Option B
Detailed Explanation: In tail recursion, the function returns the direct result of the recursive call with no pending operations (like addition or multiplication) waiting. Optimizing compilers can replace the stack-frame push with a simple jump instruction, reducing O(N) stack space to O(1).
🎯 Key Learning Point: Accumulator parameters are standard in functional and systems programming to convert standard recursion into tail-recursive forms.
Question 37 of 75 Chapter 3
What does the 'inline' function specifier suggest to the C compiler (introduced in C99)?
inline int add(int a, int b) {
    return a + b;
}
A. Forces the function to execute on a separate GPU thread.
B. Hints to the compiler to substitute the function body directly at each call site, eliminating function call overhead (stack pushing/popping).
C. Restricts the function to single-line calculations.
D. Automatically encrypts the function binary.
✔ Correct Answer: Option B
Detailed Explanation: The ‘inline’ keyword suggests that the compiler replace calls to the function with the actual machine code instructions of the function body. This eliminates call overhead (parameter pushing, branch prediction stalls, stack frame creation) at the expense of potential code size expansion.
🎯 Key Learning Point: ‘inline’ is merely an optimization hint; modern compilers may decline inlining if the function is complex, recursive, or too large.
Question 38 of 75 Chapter 3
How are function arguments passed by default in C?
A. Strictly Pass-by-Value
B. Strictly Pass-by-Reference
C. Pass-by-Name
D. Pass-by-Pointer exclusively
✔ Correct Answer: Option A
Detailed Explanation: In C, ALL function arguments are passed strictly by value. A local copy of each argument is passed into the function parameters. To achieve pass-by-reference semantics, one passes a pointer value; the pointer itself is still passed by value, but dereferencing it accesses original caller memory.
🎯 Key Learning Point: C has no native reference types (like C++ ‘int &ref’); pointers passed by value simulate pass-by-reference.
Question 39 of 75 Chapter 3
What is the consequence of declaring a variable with the 'register' storage class in C?
register int i;
A. It writes the variable directly to NVRAM.
B. It hints to the compiler to store the variable in a CPU register for fast access, and forbids taking the address of that variable using the '&' operator.
C. It makes the variable accessible across network sockets.
D. It converts the variable into an atomic spinlock.
✔ Correct Answer: Option B
Detailed Explanation: ‘register’ requests that the compiler keep the variable in a machine register rather than RAM. Because registers do not have memory addresses, attempting to use the address-of operator ‘&i’ on a register variable is an illegal compile-time error in C.
🎯 Key Learning Point: Modern optimizing compilers assign CPU registers automatically; ‘register’ is largely obsolete except for enforcing ‘&’ prohibition.
Question 40 of 75 Chapter 3
What will be printed when executing the following recursive function with input n = 4?

void print_nums(int n) {
if (n == 0) return;
print_nums(n – 1);
printf("%d ", n);
}
void print_nums(int n) {
    if (n == 0) return;
    print_nums(n - 1);
    printf("%d ", n);
}
A. 4 3 2 1
B. 1 2 3 4
C. 0 1 2 3 4
D. 4 4 4 4
✔ Correct Answer: Option B
Detailed Explanation: Because the recursive call ‘print_nums(n – 1)’ occurs BEFORE the printf statement, calls cascade down until n == 0. When the call stack unwinds in LIFO order, the print statements execute in reverse order of invocation: 1, 2, 3, 4.
🎯 Key Learning Point: Code before the recursive call executes on the way DOWN the call tree; code after the call executes on the way UP during unwinding.
Question 41 of 75 Chapter 3
Which header file and macros must be used to create functions accepting variable numbers of arguments (variadic functions) in C?
void log_msg(const char *fmt, ...);
A. <stdarg.h> (va_list, va_start, va_arg, va_end)
B. <varargs.h> (var_list, var_next)
C. <stdlib.h> (get_args, pop_arg)
D. <stdio.h> (printf_args)
✔ Correct Answer: Option A
Detailed Explanation: Variadic functions in C require ‘‘, which defines the ‘va_list’ type and the macros ‘va_start’ (to initialize the argument pointer), ‘va_arg’ (to fetch each argument by type), and ‘va_end’ (to clean up the stack state).
🎯 Key Learning Point: Every variadic function must declare at least one named parameter before the ellipsis (‘…’) to anchor va_start.
Question 42 of 75 Chapter 3
What is the return value of a function in C if the return statement is omitted in a non-void function (other than main)?
int calculate(int a) {
    int res = a * 2;
    // return omitted
}
A. 0
B. Undefined behavior if the caller uses the return value.
C. NULL
D. Compilation Error in all C compilers.
✔ Correct Answer: Option B
Detailed Explanation: If the ‘}’ that terminates a non-void function is reached and the caller attempts to use the value of the function call, the behavior is strictly undefined. The caller will read whatever residual data resides in the machine return register (e.g., EAX/RAX).
🎯 Key Learning Point: Special exception: C99/C11 defines that reaching the end of main() without a return statement is equivalent to executing ‘return 0;’.
Question 43 of 75 Chapter 3
What is the difference between a function declaration (prototype) and a function definition in C?
A. A declaration specifies the function's name and signature without a body; a definition provides the actual executable implementation body.
B. Declarations are stored in ROM; definitions are stored in RAM.
C. Declarations are processed by the linker; definitions by the preprocessor.
D. Function prototypes can only appear inside header files.
✔ Correct Answer: Option A
Detailed Explanation: A function declaration (prototype) informs the compiler of the function’s name, return type, and parameter types (e.g. ‘int add(int, int);’), allowing calls to be validated before definition. The function definition supplies the actual code block enclosed in braces.
🎯 Key Learning Point: Prototypes enable mutually recursive functions and multi-file code modularity.
Question 44 of 75 Chapter 3
What does the 'noreturn' function specifier (or '_Noreturn' in C11) signify?
_Noreturn void terminate_app();
A. The function returns a void pointer.
B. The function will never return control to the caller (e.g., calls exit() or enters an infinite loop), enabling dead-code elimination optimizations.
C. The function cannot contain return types.
D. The function cannot call other functions.
✔ Correct Answer: Option B
Detailed Explanation: ‘_Noreturn’ informs the compiler that the function will never return to its call site (e.g. abort(), exit()). This allows the compiler to suppress unused variable warnings and optimize stack cleanup.
🎯 Key Learning Point: Available via ‘_Noreturn’ in C11 or ‘‘ which defines ‘noreturn’.
Question 45 of 75 Chapter 3
In C, what is the maximum number of values a function can return directly via the return statement?
A. Multiple values separated by commas.
B. Exactly one value (though it can be a struct containing multiple fields).
C. Up to 4 values depending on CPU register count.
D. Unlimited values if passed by reference.
✔ Correct Answer: Option B
Detailed Explanation: The C return statement returns at most one single value. However, that value can be a composite structure (‘struct’) containing multiple sub-variables, or multiple values can be returned via pointer arguments.
🎯 Key Learning Point: To return multiple values in C: 1) Pass output pointers as arguments, or 2) Return a struct by value.
Curriculum Track • Module 4 of 5
Chapter 4: Control Structures, Loops & Logic (Q46 – Q60)
Question 46 of 75 Chapter 4
What happens if a 'break' statement is omitted at the end of a 'case' block in a C switch statement?
switch(val) {
    case 1: printf("A ");
    case 2: printf("B "); break;
}
A. The program raises a syntax error.
B. Fall-through occurs: execution continues sequentially into the subsequent case block regardless of whether its condition matches.
C. The switch statement terminates immediately.
D. The CPU register state is reset.
✔ Correct Answer: Option B
Detailed Explanation: Without a ‘break’ statement, C switch statements exhibit ‘fall-through’ behavior. Execution simply proceeds into the instructions of the next case label, ignoring its comparison condition until hitting a break or the end of the switch block.
🎯 Key Learning Point: Fall-through can be useful (e.g., Duff’s device or grouping cases), but unintended fall-through is a frequent source of logic bugs.
Question 47 of 75 Chapter 4
What data types are legally permitted as the expression inside a switch() statement in C?
A. Any type including float, double, and struct.
B. Strictly integral types (int, char, short, long, enum).
C. Floating-point numbers and strings only.
D. Pointers exclusively.
✔ Correct Answer: Option B
Detailed Explanation: The controlling expression of a switch statement in C must evaluate to an integer type (including signed/unsigned char, short, int, long, and enumerations). Floating-point values (float/double), strings, and structs are strictly forbidden.
🎯 Key Learning Point: To branch on strings in C, you must use cascaded if-else chains with strcmp() instead of a switch statement.
Question 48 of 75 Chapter 4
What is the primary difference between a 'while' loop and a 'do-while' loop in C?
A. 'while' loops execute at least once; 'do-while' loops test the condition first.
B. 'while' is an entry-controlled loop (condition checked before loop body); 'do-while' is an exit-controlled loop (loop body executes at least once before condition check).
C. 'do-while' loops cannot contain break statements.
D. 'while' loops run only on even numbers.
✔ Correct Answer: Option B
Detailed Explanation: In a ‘while’ loop, the condition is evaluated prior to the first iteration, meaning the body may execute 0 times if initially false. A ‘do-while’ loop evaluates the condition at the end of the block, guaranteeing that the body executes at least once.
🎯 Key Learning Point: Use do-while loops for input validation menus where prompt display must occur at least once.
Question 49 of 75 Chapter 4
What is the behavior of the 'continue' statement when executed inside a C 'for' loop?
for (int i = 0; i < 5; i++) {
    if (i == 2) continue;
    printf("%d ", i);
}
A. It terminates the entire loop immediately.
B. It skips the remaining statements in the current iteration and jumps directly to the loop iteration expression ('i++'), then evaluates the condition.
C. It jumps back to the initialization expression.
D. It resets 'i' back to 0.
✔ Correct Answer: Option B
Detailed Explanation: In a ‘for’ loop, executing ‘continue’ skips remaining body statements and immediately executes the iteration/update step (i++). It then evaluates the conditional test. (In a while loop, continue jumps directly to the condition test).
🎯 Key Learning Point: Be cautious using ‘continue’ in while loops: if the loop increment is after the continue statement, an infinite loop can result.
Question 50 of 75 Chapter 4
What will be printed when executing the following nested loop?

int count = 0;
for (int i = 0; i < 3; i++)
for (int j = 0; j < 4; j++)
count++;
printf("%d", count);
int count = 0;
for (int i = 0; i < 3; i++)
    for (int j = 0; j < 4; j++)
        count++;
printf("%d", count);
A. 7
B. 12
C. 9
D. 16
✔ Correct Answer: Option B
Detailed Explanation: The outer loop runs 3 times (i = 0, 1, 2). For each iteration of the outer loop, the inner loop executes 4 times (j = 0, 1, 2, 3). Total iterations = 3 * 4 = 12.
🎯 Key Learning Point: Nested loops multiply iterations, demonstrating O(N * M) time complexity.
Question 51 of 75 Chapter 4
What is the scope restriction of the 'goto' statement in C?
A. A goto statement can jump to any function in any source file.
B. A goto statement can only jump to a labeled statement within the exact same function.
C. A goto statement can only jump backwards, never forwards.
D. A goto statement can only jump between switch cases.
✔ Correct Answer: Option B
Detailed Explanation: In C, labels have function scope. A ‘goto’ statement can only transfer control to a label located within the same function body. It cannot jump across function boundaries.
🎯 Key Learning Point: To jump across function boundaries, standard C provides ‘setjmp()’ and ‘longjmp()’ from .
Question 52 of 75 Chapter 4
What will occur if the condition expression is completely omitted in a for loop: 'for ( ; ; ) { … }'?
for ( ; ; ) {
    // body
}
A. Compile error: missing condition.
B. The loop runs exactly once and terminates.
C. An infinite loop: an omitted condition in a for loop evaluates to true (1) by standard definition.
D. The compiler fills in '0' and skips the loop.
✔ Correct Answer: Option C
Detailed Explanation: According to the C standard (§6.8.5.3), if clause-2 (the controlling condition) of a for loop is omitted, it is treated as if replaced by a non-zero constant (true). Thus, ‘for (;;)’ creates an intentional infinite loop.
🎯 Key Learning Point: ‘for (;;)’ and ‘while (1)’ are common idiom equivalents for indefinite event loops in systems programming.
Question 53 of 75 Chapter 4
What is the output of the following code snippet?

int x = 0;
if (x++)
printf("A ");
else
printf("B ");
printf("%d", x);
int x = 0;
if (x++)
    printf("A ");
else
    printf("B ");
printf("%d", x);
A. A 1
B. B 1
C. B 0
D. A 0
✔ Correct Answer: Option B
Detailed Explanation: The post-increment ‘x++’ evaluates to the current value of x (0, which is false in C) for the if condition. After evaluation, x is incremented to 1. The ‘else’ branch executes, printing ‘B ‘, followed by the final value of x, which is 1.
🎯 Key Learning Point: Post-increment yields the original value before modifying the variable.
Question 54 of 75 Chapter 4
Can a 'default' case be placed at the top or middle of a switch statement in C rather than at the bottom?
switch(val) {
    default: printf("Def "); break;
    case 1: printf("One "); break;
}
A. No, it must always be the final case.
B. Yes, the position of the 'default' label inside a switch is arbitrary; it is only evaluated if no matching 'case' label matches.
C. It results in a syntax error on 64-bit systems.
D. Placing default first causes it to always execute.
✔ Correct Answer: Option B
Detailed Explanation: In C, the ‘default’ label can appear anywhere within the switch block (beginning, middle, or end). Regardless of its placement, the switch engine checks all explicit case matches first; default only triggers if no matching case is found.
🎯 Key Learning Point: If default is placed at the top or middle, ensure it ends with a ‘break’ to avoid unintended fall-through into following cases.
Question 55 of 75 Chapter 4
What will be printed when executing this loop?

int i = 5;
while (i –> 0) {
printf("%d ", i);
}
int i = 5;
while (i --> 0) {
    printf("%d ", i);
}
A. 5 4 3 2 1
B. 4 3 2 1 0
C. 5 4 3 2 1 0
D. Syntax error on '–>'
✔ Correct Answer: Option B
Detailed Explanation: ‘–>’ is not a single operator; it is parsed by the C lexer as ‘(i–) > 0’. When i = 5, (5 > 0) is true, i decrements to 4, printing 4. When i = 1, (1 > 0) is true, i decrements to 0, printing 0. When i = 0, (0 > 0) is false, i decrements to -1, and loop exits. Printed: 4 3 2 1 0.
🎯 Key Learning Point: The ‘goes-to’ operator (–>) illustrates maximal munch tokenization in C compilers: parsed as post-decrement followed by greater-than.
Question 56 of 75 Chapter 4
What is the primary danger of using floating-point loop control variables, such as 'for (float f = 0.0f; f != 1.0f; f += 0.1f)'?
for (float f = 0.0f; f != 1.0f; f += 0.1f) {
    // ...
}
A. Floating point math is unsupported on CPUs.
B. Rounding errors in binary floating point representation mean f may never equal 1.0f exactly, creating an infinite loop.
C. It causes immediate integer overflow.
D. The compiler rejects float declarations in for loops.
✔ Correct Answer: Option B
Detailed Explanation: Because 0.1 cannot be represented precisely in IEEE 754 binary floating-point, accumulating 0.1 repeatedly introduces fractional rounding errors. Consequently, ‘f’ might reach 0.99999994 and then 1.0000001, never matching ‘!= 1.0f’ exactly.
🎯 Key Learning Point: Always use integer loop counters: ‘for (int i = 0; i < 10; i++) { float f = i * 0.1f; }'.
Question 57 of 75 Chapter 4
What is the effect of an empty statement ';' inside a while loop header: 'while (condition);'?
int i = 0;
while (i < 5);
{
    i++;
}
A. The compiler deletes the semicolon.
B. The semicolon acts as a null statement representing the entire loop body; if 'condition' is true, the loop spins infinitely without executing the following braced block.
C. The loop executes the block once.
D. Generates a syntax error.
✔ Correct Answer: Option B
Detailed Explanation: The trailing semicolon after ‘while (i < 5);' constitutes the complete body of the loop. Because 'i' is never incremented inside that null body, (0 < 5) remains true forever, trapping the program in an infinite busy-wait.
🎯 Key Learning Point: Never place an accidental semicolon directly after a while, if, or for statement unless an intentional null body is desired.
Question 58 of 75 Chapter 4
In a switch statement, can two different 'case' labels share the exact same constant value?
switch(x) {
    case 1: ... break;
    case 1: ... break;
}
A. Yes, both will execute.
B. No, duplicate case values within the same switch block produce a compile-time error.
C. Yes, the second one overrides the first.
D. Allowed only if separated by default.
✔ Correct Answer: Option B
Detailed Explanation: The C standard specifies that no two case constant expressions in the same switch statement may evaluate to the identical value. The compiler reports an error: ‘duplicate case value’.
🎯 Key Learning Point: Case expressions must be unique compile-time integer constants.
Question 59 of 75 Chapter 4
What is the purpose of 'Duff’s Device' in C programming?
A. A hardware device for measuring CPU temperature.
B. An unrolled loop optimization idiom that interleaves a switch statement with a do-while loop to copy serial chunks with minimal branch penalty.
C. An algorithm to encrypt passwords.
D. A garbage collection utility.
✔ Correct Answer: Option B
Detailed Explanation: Invented by Tom Duff, Duff’s Device exploits C’s switch fall-through to interleave a switch statement within a do-while loop. It achieves manual loop unrolling, handling arbitrary length buffers with minimal branch checks.
🎯 Key Learning Point: Duff’s Device demonstrates the legal flexibility of statement nesting and label jumps in C.
Question 60 of 75 Chapter 4
What does a 'break' statement do when executed inside a nested loop in C?
for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
        if (j == 1) break;
    }
}
A. Breaks out of all nested loops back to main().
B. Breaks out of ONLY the innermost enclosing loop or switch block.
C. Terminates the outer loop.
D. Causes the program to exit.
✔ Correct Answer: Option B
Detailed Explanation: The ‘break’ statement terminates execution of only the immediately enclosing switch, while, do, or for statement. It does not break out of outer enclosing loops.
🎯 Key Learning Point: To exit multiple deeply nested loops at once, developers typically use a ‘goto’ to a label placed immediately after the outermost loop.
Curriculum Track • Module 5 of 5
Chapter 5: Arrays, Strings, Structs & File I/O (Q61 – Q75)
Question 61 of 75 Chapter 5
What character implicitly terminates all valid C string literals in memory?
A. '\n' (Newline)
B. '\0' (Null terminator / byte 0x00)
C. '\t' (Horizontal tab)
D. EOF (-1)
✔ Correct Answer: Option B
Detailed Explanation: C strings are zero-terminated arrays of characters. The null character ‘\0’ (ASCII 0) marks the end of the character sequence in memory, allowing functions like strlen(), strcpy(), and printf(“%s”) to detect string bounds.
🎯 Key Learning Point: An array holding an N-character string must allocate at least N + 1 bytes to accommodate the null terminator.
Question 62 of 75 Chapter 5
What is 'Structure Padding' and alignment in C?
struct Example {
    char a;    // 1 byte
    int b;     // 4 bytes
};
A. Encrypting structure members for cybersecurity.
B. Unused filler bytes inserted by the compiler between struct members to align data types to CPU word boundary multiples for optimal memory bus performance.
C. Adding extra bytes to round the struct size to 100 bytes.
D. Compressing struct data into bitfields.
✔ Correct Answer: Option B
Detailed Explanation: CPUs access memory most efficiently when data types reside at memory addresses divisible by their size (e.g. 4-byte integers on 4-byte boundaries). Compilers automatically insert padding bytes between members (e.g., 3 padding bytes after ‘char a’ before ‘int b’), making sizeof(struct Example) = 8 bytes instead of 5.
🎯 Key Learning Point: Order struct members from largest to smallest to minimize compiler padding overhead.
Question 63 of 75 Chapter 5
How does a 'union' differ from a 'struct' in C?
union Data {
    int i;
    float f;
    char str[20];
};
A. Struct members share memory; union members have separate memory.
B. All union members share the exact same memory location, and the size of the union equals the size of its largest member; a struct allocates separate memory for each member.
C. Unions cannot contain arrays.
D. Unions can only be declared inside functions.
✔ Correct Answer: Option B
Detailed Explanation: In a union, all member fields overlap in the exact same memory address. Writing to one member overwrites the others. A union’s total memory allocation is determined strictly by the size of its largest member (plus alignment requirements).
🎯 Key Learning Point: Unions are used to implement type punning, variant types (tagged unions), and low-level hardware register overlays.
Question 64 of 75 Chapter 5
Why is the standard library function 'gets()' considered hazardous and formally removed from the C11 standard?
char buf[50];
gets(buf); // DEPRECATED & REMOVED
A. It operates too slowly on modern SSDs.
B. It has no mechanism to limit the number of characters read, creating fatal buffer overflow vulnerabilities if input exceeds buffer capacity.
C. It converts lowercase letters to uppercase.
D. It requires superuser root privileges.
✔ Correct Answer: Option B
Detailed Explanation: ‘gets()’ reads lines from stdin until a newline is reached without accepting a buffer size limit parameter. If user input exceeds the target array size, adjacent stack memory is overwritten, causing crashes or arbitrary code execution exploits. C11 removed gets() entirely.
🎯 Key Learning Point: Always replace ‘gets()’ with ‘fgets(buffer, sizeof(buffer), stdin)’ to enforce strict buffer size limits.
Question 65 of 75 Chapter 5
What does the file open mode "r+" specify in fopen()?
FILE *fp = fopen("data.txt", "r+");
A. Open for reading only; fails if file does not exist.
B. Open an existing file for both reading and writing; the file must already exist, and writes do not automatically truncate existing contents.
C. Create a new file for writing, discarding existing contents.
D. Open for append-only writing at the end of the file.
✔ Correct Answer: Option B
Detailed Explanation: “r+” opens an existing file for both reading and writing (update mode). The stream is positioned at the beginning of the file. If the file does not exist, fopen() fails and returns NULL.
🎯 Key Learning Point: “w+” creates/truncates the file; “a+” appends to the file; “r+” reads and writes an existing file without truncating.
Question 66 of 75 Chapter 5
What will be printed when comparing two identical string literals using '==' instead of 'strcmp()' in C?

char s1[] = "test";
char s2[] = "test";
if (s1 == s2) printf("Same"); else printf("Diff");
char s1[] = "test";
char s2[] = "test";
if (s1 == s2) printf("Same"); else printf("Diff");
A. Same
B. Diff
C. Compilation Error
D. Runtime Exception
✔ Correct Answer: Option B
Detailed Explanation: In C, using ‘==’ on arrays compares their pointer memory addresses, not their string text contents. Because s1 and s2 are two separate stack arrays allocated at different memory addresses, (s1 == s2) evaluates to false (0), printing ‘Diff’.
🎯 Key Learning Point: Always use ‘strcmp(s1, s2) == 0’ to compare string contents lexicographically in C.
Question 67 of 75 Chapter 5
What is the return value of 'fclose(fp)' upon successful closure of a file stream?
A. 1
B. 0
C. EOF (-1)
D. NULL
✔ Correct Answer: Option B
Detailed Explanation: ‘fclose()’ flushes any unwritten buffered data to disk and closes the underlying operating system file descriptor. It returns 0 upon successful closure; if an error occurs, it returns EOF (-1).
🎯 Key Learning Point: Always check the return value of fclose() when writing critical files to detect delayed I/O write failures.
Question 68 of 75 Chapter 5
What is a 'Bit-field' inside a C structure definition?
struct Flags {
    unsigned int is_ready : 1;
    unsigned int mode     : 3;
};
A. A binary file format on disk.
B. A struct member declared with explicit bit width, allowing packing multiple data fields tightly into fractional byte boundaries.
C. A bitwise operator.
D. An encryption key generator.
✔ Correct Answer: Option B
Detailed Explanation: Bit-fields allow programmers to define struct members with an exact bit width (e.g., ‘: 1’ allocates 1 single bit, ‘: 3’ allocates 3 bits). This allows packing flags and hardware register masks compactly into memory.
🎯 Key Learning Point: You cannot take the address-of (‘&’) a bit-field member because memory addresses in C are byte-granular.
Question 69 of 75 Chapter 5
What function in the standard library safely copies at most N bytes from one string to another, helping prevent buffer overflows?
A. strcpy()
B. strncpy() / strlcpy()
C. strcat()
D. sprintf()
✔ Correct Answer: Option B
Detailed Explanation: ‘strncpy(dest, src, n)’ copies at most n characters from src to dest. (Note: if src has n or more characters, strncpy does NOT append a null terminator, so manual null-termination ‘dest[n-1] = ‘\0” is required).
🎯 Key Learning Point: On modern BSD/Linux/macOS platforms, ‘strlcpy(dest, src, size)’ guarantees null-termination.
Question 70 of 75 Chapter 5
What is the function of 'fseek(fp, offset, whence)' in C file operations?
A. Searches for a text string in the file.
B. Repositions the file position indicator of the stream to a specified byte offset relative to SEEK_SET, SEEK_CUR, or SEEK_END.
C. Deletes bytes from the file.
D. Encrypts the file.
✔ Correct Answer: Option B
Detailed Explanation: ‘fseek()’ sets the file position indicator. The ‘whence’ argument specifies the reference point: SEEK_SET (start of file), SEEK_CUR (current position), or SEEK_END (end of file).
🎯 Key Learning Point: To get total file size: ‘fseek(fp, 0, SEEK_END); long sz = ftell(fp); fseek(fp, 0, SEEK_SET);’.
Question 71 of 75 Chapter 5
What is the return value of 'feof(fp)' in C?
A. It returns non-zero ONLY after an attempt has been made to read past the end of the file.
B. It returns true before reading if the next byte is the last byte.
C. It returns the total number of characters in the file.
D. It returns the current line number.
✔ Correct Answer: Option A
Detailed Explanation: ‘feof()’ tests the end-of-file indicator on a stream. It only becomes true AFTER a read operation (like fgetc or fread) attempts to read past EOF. Testing ‘while (!feof(fp))’ before reading leads to off-by-one errors reading the last item twice.
🎯 Key Learning Point: Correct idiom: Test the return value of the read function itself: ‘while ((ch = fgetc(fp)) != EOF)’.
Question 72 of 75 Chapter 5
What does the 'typedef' keyword accomplish in C?
typedef unsigned long long uint64_t;
A. It allocates a new memory type in the CPU cache.
B. It creates a new type alias (synonym) for an existing data type without creating a brand new underlying type.
C. It converts variables to constant values.
D. It generates an external linkage header.
✔ Correct Answer: Option B
Detailed Explanation: ‘typedef’ creates an identifier that can be used as an alias for an existing type. It simplifies complex declarations (like function pointers: ‘typedef void (*callback_t)(int);’) and enhances portable code definitions.
🎯 Key Learning Point: ‘typedef’ is processed by the compiler (honoring scope), whereas ‘#define’ is a dumb text-substitution by the preprocessor.
Question 73 of 75 Chapter 5
What is the difference between binary file mode ("rb", "wb") and text file mode ("r", "w") in C on Windows platforms?
A. Binary mode encrypts files; text mode leaves them unencrypted.
B. Text mode automatically translates newline characters ('\n' <-> '\r\n') during read/write; binary mode reads and writes raw byte streams without translation.
C. Binary mode can only be read by machines; text mode only by humans.
D. Binary mode does not support fseek().
✔ Correct Answer: Option B
Detailed Explanation: On Windows/DOS systems, text mode translates single newline characters ‘\n’ into carriage-return line-feed pairs ‘\r\n’ on write, and reverse on read. Binary mode (“rb”, “wb”) performs zero translation, preserving exact byte values (vital for image files, compiled binaries, and protocol payloads).
🎯 Key Learning Point: On POSIX systems (Linux/macOS), binary and text modes are identical because newlines are single ‘\n’ bytes.
Question 74 of 75 Chapter 5
What does the 'fflush(fp)' function do on an output stream?
fflush(stdout);
A. Clears the screen buffer.
B. Forces any unwritten buffered data in the user-space stream buffer to be written immediately to the underlying file or device.
C. Re-reads data from disk.
D. Deallocates the file pointer.
✔ Correct Answer: Option B
Detailed Explanation: Standard I/O streams use user-space buffers (block or line buffered). Calling ‘fflush(fp)’ on an output or update stream immediately delivers all buffered data to the operating system’s write queue.
🎯 Key Learning Point: Note: In ISO C, calling ‘fflush()’ on an INPUT stream (like ‘fflush(stdin)’) yields undefined behavior.
Question 75 of 75 Chapter 5
How does 'snprintf()' differ from 'sprintf()' in C?
snprintf(buf, sizeof(buf), "User ID: %d", id);
A. sprintf is faster because it bypasses memory.
B. snprintf accepts a maximum buffer size parameter, guaranteeing that it will never write past the buffer boundary and will always append a terminating null character (if size > 0).
C. snprintf works only with numbers.
D. There is no difference.
✔ Correct Answer: Option B
Detailed Explanation: ‘sprintf()’ writes formatted text to a buffer without bounds checking, making it a major security risk for buffer overflows. ‘snprintf(buf, size, …)’ takes the buffer size, truncates output if it exceeds (size – 1), and guarantees null termination.
🎯 Key Learning Point: Always replace ‘sprintf()’ with ‘snprintf()’ in production code to prevent security vulnerabilities.

Explore Other Comprehensive 75-Question Subject Tracks

Continue your preparation across our active curriculum tracks. Every track provides 75 verified questions across 5 complete chapters.

Active Track
📍 C Programming
75 Qs • 5 Chapters (You are here)
🟢 100% Live Track
Python Programming
75 Qs • 5 Chapters • Practice Now →
🟢 100% Live Track
Data Structures
75 Qs • 5 Chapters • Practice Now →
🟢 100% Live Track
DBMS & SQL
75 Qs • 5 Chapters • Practice Now →
🟢 100% Live Track
Computer Networks
75 Qs • 5 Chapters • Practice Now →
🟢 100% Live Track
Operating Systems
75 Qs • 5 Chapters • Practice Now →
🟢 100% Live Track
Quantitative Aptitude
75 Qs • 5 Chapters • Practice Now →
📚 View All 92+ Subjects in Master Directory
Share
  • Facebook
Queryiest

Queryiest

Enlightened

Queryiest – Technology Writer | Software Developer | Digital Learning Enthusiast

Queryiest is a technology writer, software developer, and knowledge-sharing enthusiast passionate about simplifying complex technical concepts for students, professionals, and lifelong learners. With expertise in software development, programming, cybersecurity, artificial intelligence, digital tools, and emerging technologies, Queryiest creates practical, research-driven content that helps readers solve real-world problems. As a regular contributor to RTSALL, Queryiest publishes easy-to-understand guides, coding resources, technology news, career advice, and educational tutorials designed for beginners and professionals alike. Every article focuses on accuracy, clarity, and actionable insights to help readers stay informed in the rapidly evolving digital world. Whether it's programming, software engineering, AI, cybersecurity, online platforms, or digital productivity, Queryiest believes that quality knowledge should be accessible to everyone. The goal is to build a trusted learning resource where readers can discover reliable answers, improve their technical skills, and make informed decisions. Areas of Expertise: Software Development, Programming, Cybersecurity, Artificial Intelligence, Technology News, Coding Interview Preparation, Digital Learning, Productivity Tools, and Online Knowledge Sharing.

    Sidebar

    Ask A Question
    • Popular
    • Answers
    • Queryiest

      What is a database?

      • 3 Answers
    • Anonymous

      How to rotate an array in-place with O(1) space and ...

      • 3 Answers
    • hannah

      What steps can businesses take to identify the most valuable ...

      • 2 Answers
    • Vikram
      aarav0 added an answer Direct Technical Solution: Unlike IVFFlat (which partitions vector spaces with… September 11, 2026 at 9:57 pm
    • Abhishek
      Abhishek added an answer Direct Technical Solution: In C++20, range view adaptors (like std::views::filter,… September 11, 2026 at 9:57 pm
    • Sneha Patel
      Anonymous added an answer Direct Technical Solution: torch.cuda.empty_cache() releases only cached (unallocated) blocks back… September 11, 2026 at 9:57 pm

    Top Members

    Queryiest

    Queryiest

    • 201 Questions
    • 295 Points
    Enlightened
    Anonymous

    Anonymous

    • 11 Questions
    • 42 Points
    Begginer
    paperubofficial

    paperubofficial

    • 0 Questions
    • 22 Points
    Begginer

    Trending Tags

    ai asp.net aws basics aws certification aws console aws free tier aws login aws scenario-based questions c++ career cyber security cyber security interview git java javascript jobs jquery net core net core interview questions sql

    Explore

    • Home
    • Add group
    • Groups page
    • Communities
    • Questions
      • DSA Problems
    • Polls
    • Tags
    • Badges
    • Users
    • Help
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions

    Footer

    About Us

    • Meet The Team
    • Blog
    • About Us
    • Contact Us

    Legal Stuff

    • Privacy Policy
    • Disclaimer
    • Terms & Conditions

    Help

    • Knowledge Base
    • Support

    Follow

    © 2023-25 RTSALL. All Rights Reserved