1. Introduction
This study set compiles commonly repeated previous-year exam and viva-style questions on C programming, organized by topic area, to help students revise efficiently before university exams, campus placement tests, or certification assessments. Rather than introducing new theory, this page focuses on practice: a curated list of questions grouped by topic (basics, control flow, functions, pointers, and data structures) so you can test your recall and identify weak areas quickly.
Cricket analogy: Compiling past exam questions is like a coach handing batters a dossier of deliveries bowled by Bumrah in previous nets sessions, so they can revise weak strokes before the actual match instead of facing surprises.
2. Syntax
This topic is a review/practice guide rather than a syntax reference. Refer to the individual topic pages (variables-in-c, loops-in-c, functions-in-c, pointers-in-c, linked-list-basics-in-c) for exact syntax of each construct referenced in the practice questions below.
Cricket analogy: This page is like a net-practice schedule pointing to specialist coaching manuals for batting, bowling and fielding rather than being the coaching manual itself — you still consult the pointers-in-c style guide for technique.
3. Explanation
Exam papers typically test five core areas of C in roughly equal weight: language basics, control flow, functions, pointers/memory, and data structures. Below, practice questions are grouped by these five areas. Attempt each question from memory first, then verify your answer against the linked topic pages for full explanations.
Cricket analogy: Just as a five-day Test is judged across batting, bowling, fielding, running between wickets and captaincy, C exams weigh basics, control flow, functions, pointers and data structures roughly equally.
Basics — Practice Questions
- Differentiate between a variable declaration and a variable definition in C, with an example of each.
- List the primary data types in C and give the typical size (in bytes) of each on a 64-bit system.
- What is the difference between #define and const for creating constants?
- Explain the four storage classes in C: auto, extern, static, and register.
- What is type casting? Differentiate implicit and explicit type conversion with an example.
Control Flow — Practice Questions
- Differentiate between while, do-while, and for loops, including a case where do-while is more appropriate.
- What is the difference between break and continue inside a loop?
- Explain switch-case fall-through behavior and how the break keyword prevents it.
- What is the difference between an if-else ladder and a switch statement, and when would you prefer one over the other?
- Write the output of a nested loop that prints a right-angled triangle pattern of stars for n rows.
Functions — Practice Questions
- What is recursion? Write a recursive function to compute factorial and identify its base case.
- Differentiate between call by value and call by reference (simulated via pointers) in C.
- What is function overloading, and why is it not supported in standard C (unlike C++)?
- Explain the concept of a function prototype and why it is needed before a function's first use.
- What is the difference between actual parameters and formal parameters?
Pointers & Memory — Practice Questions
- What is a pointer? Explain pointer declaration, initialization, and dereferencing with an example.
- Differentiate between a NULL pointer, a void pointer, and a dangling pointer.
- Explain pointer arithmetic: what happens when you increment a pointer to an int versus a pointer to a char?
- What is a double pointer (pointer to pointer)? Give a practical use case.
- Differentiate between static memory allocation and dynamic memory allocation (malloc/calloc/realloc/free).
Data Structures — Practice Questions
- Write a C function to insert a node at the beginning of a singly linked list.
- Differentiate between an array and a linked list in terms of memory allocation and access time.
- Explain how a stack can be implemented using an array, and describe the push and pop operations.
- Explain how a queue differs from a stack in terms of insertion and deletion order (FIFO vs LIFO).
- What is a structure in C, and how does it differ from a union in terms of memory allocation?
4. Example
Two frequently repeated code-based exam questions with their expected solutions are shown below.
Cricket analogy: Two frequently asked code questions are like the yorker and the bouncer — deliveries repeated so often in nets that every serious batter, like Kohli, drills them until the response is automatic.
/* Exam Question: Write a C program to check whether a given number
is a palindrome using pointers/loops only (no string functions). */
#include <stdio.h>
int isPalindrome(int num) {
int original = num, reversed = 0;
while (num != 0) {
int digit = num % 10;
reversed = reversed * 10 + digit;
num /= 10;
}
return original == reversed;
}
int main(void) {
int n = 12321;
if (isPalindrome(n)) {
printf("%d is a palindrome\n", n);
} else {
printf("%d is not a palindrome\n", n);
}
return 0;
}/* Exam Question: Write a C program to insert a node at the
beginning of a singly linked list. */
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
struct Node *next;
};
struct Node *insertAtBeginning(struct Node *head, int value) {
struct Node *newNode = (struct Node *)malloc(sizeof(struct Node));
newNode->data = value;
newNode->next = head;
return newNode; /* new node becomes the head */
}
void printList(struct Node *head) {
while (head != NULL) {
printf("%d -> ", head->data);
head = head->next;
}
printf("NULL\n");
}
int main(void) {
struct Node *head = NULL;
head = insertAtBeginning(head, 30);
head = insertAtBeginning(head, 20);
head = insertAtBeginning(head, 10);
printList(head);
return 0;
}5. Output
12321 is a palindrome
10 -> 20 -> 30 -> NULL6. Key Takeaways
- Exam papers consistently repeat five theme areas: basics, control flow, functions, pointers/memory, and data structures — revise all five, not just coding questions.
- Practice writing full programs by hand (palindrome check, factorial, linked list operations) since handwritten exams don't offer a compiler for syntax checking.
- Be ready to explain 'why', not just 'what' — e.g., why do-while guarantees at least one execution, why recursion needs a base case.
- Trace-based questions (predict the output) are common; always mentally simulate loop variables and pointer values step by step.
- Data structure questions (linked list insertion, stack/queue via array) are the most frequently repeated code-writing questions across previous papers.
Practice what you learned
1. Which loop construct guarantees that its body executes at least once, regardless of the condition?
2. In the palindrome-check exam question, what does the expression 'reversed = reversed * 10 + digit' accomplish?
3. In the linked list insertAtBeginning() function, why must newNode->next be set to the current head before returning newNode as the new head?
4. What is the key difference between break and continue inside a loop?
5. Why is function overloading (same function name, different parameter types) not supported in standard C?
Was this page helpful?
You May Also Like
Linked List Basics in C
Learn singly linked lists in C: node structs, malloc-based insertion, traversal, and time complexity, with a full compilable example.
Pointers in C
Learn C pointers with syntax, address-of and dereference operators, pointer arithmetic, and common pitfalls, with examples and output.
Recursion in C
Master recursion in C: base case, recursive case, call-stack tracing, factorial example, and avoiding stack overflow.
Related Reading
Related Study Notes in Programming
Browse all study notesApache Spark Study Notes
Programming · 30 topics
ProgrammingApache Flink Study Notes
Programming · 30 topics
ProgrammingHadoop Study Notes
Programming · 30 topics
ProgrammingSnowflake Study Notes
Programming · 30 topics
ProgrammingApache Airflow Study Notes
Programming · 30 topics
Programmingdbt (Data Build Tool) Study Notes
Programming · 30 topics