C is a foundational programming language. Questions in the exam often test your understanding of syntax, logic, and memory management in C.
1. Pointers
A pointer is a variable that stores the memory address of another variable. It is a powerful feature for direct memory manipulation.
- Declaration:
int *ptr; - Address-of Operator (&): Gets the address of a variable (e.g.,
ptr = &var;). - Dereference Operator (*): Accesses the value stored at the memory address (e.g.,
value = *ptr;).
2. Arrays and Strings
An array is a collection of elements of the same data type stored in contiguous memory locations. In C, the array name acts as a constant pointer to the first element.
Strings in C are simply arrays of characters, terminated by a null character ('\0').
When passing arguments to functions, 'Pass by Value' copies the value. Modifications inside the function don't affect the original variable. 'Pass by Reference' (using pointers in C) passes the memory address, allowing the function to modify the original variable.
High-Yield Practice Questions & Worked Examples
Test your understanding with these exam-standard questions specifically calibrated for the syllabus pattern:
Q: What is the output of the following C code snippet? int arr[] = {10, 20, 30, 40}; int *ptr = arr; printf("%d", *(ptr + 2));
- (A) 10
- (B) 20
- (C) 30
- (D) 40
✓ Correct Answer: (C) 30
Detailed Explanation: In C, arr decays into a pointer to its first element arr[0] (value 10). *(ptr + 2) shifts the pointer forward by 2 integer elements, pointing to arr[2], which evaluates to 30.
Q: What memory allocation function in C initializes all allocated bytes to zero?
- (A) malloc()
- (B) calloc()
- (C) realloc()
- (D) free()
✓ Correct Answer: (B) calloc()
Detailed Explanation: calloc(n, size) allocates memory for an array of n elements of size bytes and clears all memory bits to zero. malloc() leaves allocated memory uninitialized with garbage values.
Recommended Deep Dives & Related Study Notes
Explore connected topics in the official Gujarat WPSI & GPSC syllabus
Data Structures: Stacks, Queues, and Trees
Implementing linked nodes and dynamic memory in C
Related Guide →Object-Oriented Programming (OOP) Concepts
Transitioning from procedural C to object-oriented C++
Related Guide →Software Engineering: SDLC Models
Writing maintainable code across software lifecycles
Sharpen Your Exam Readiness on Mcqprepzone
Mastering technical formulas and theoretical concepts is only step one. Solving timed mock tests under exact exam conditions improves speed, eliminates negative marking, and reveals your weak spots.
Frequently Asked Questions
What is a Dangling Pointer in C?
A dangling pointer points to a memory location that has already been deallocated using free(). Accessing it causes undefined behavior or segmentation faults. It should be assigned NULL immediately after freeing.
What is the size of a pointer in C on a 64-bit operating system?
On a 64-bit system, all data pointers have a size of 8 bytes (64 bits), regardless of whether they point to a char, int, float, or custom struct.
What is the difference between a Structure and a Union in C?
In a Structure, every member has its own separate memory location, so sizeof(struct) is the sum of member sizes (plus padding). In a Union, all members share the same single memory location, so sizeof(union) is simply the size of its largest member.
MCQ Prep Zone Study Hub & Quick Links
Practice syllabus questions, mock exams, and download study notes
Topic-Wise MCQs
Unit-wise practice with detailed explanations.
Mock Tests →Full-Length Mocks
Simulated test papers with negative marking.
Exams Hub →Govt Exams Guides
Gujarat WPSI, GPSC AE, and CCE notifications.
Formulas →Study Notes & PDFs
Concise formula sheets for rapid revision.
Daily Drill →Daily MCQ Challenge
Compete daily, earn points, and build streaks.
Membership →Test Series Plans
Unlock all sectional tests & ranking analytics.
Related Strategy & Syllabus Articles
Strengthen your exam preparation across adjacent subjects