Sample Question Paper: C Programming
Calcutta University - Computer Science (CC-3: Data Structures)
Semester: II, Academic Year: 2024-2025
Time: 2 Hours Full Marks: 50
Instructions:
• Answer all questions.
• Marks are indicated against each question.
• Provide code snippets where required, ensuring correct syntax.
• Answers should be concise and clear.
Section A: Multiple Choice Questions (10 Marks, 2 marks each)
1. Which of the following is the correct syntax to declare a pointer in C?
a) int p;
b) int *p;
c) int p;
d) int p*;
Answer: b) int *p;
2. What is the output of printf("%d", sizeof(int)); on a 32-bit system?
a) 2
b) 4
c) 8
d) 16
Answer: b) 4
3. Which loop in C is guaranteed to execute at least once?
a) for
b) while
c) do-while
d) switch
Answer: c) do-while
4. What does the break statement do in a C loop?
a) Terminates the program
b) Exits the current loop
c) Skips to the next iteration
d) Restarts the loop
Answer: b) Exits the current loop
1
5. Which function is used to allocate memory dynamically in C?
a) alloc()
b) malloc()
c) new()
d) calloc()
Answer: b) malloc()
Section B: Short Answer Questions (20 Marks, 5 marks each)
6. Explain the difference between call by value and call by reference in C.
Provide an example of call by reference using pointers.
7. Write a C program to find the factorial of a number using a recursive function.
8. Describe the purpose of the struct keyword in C. Provide an example of defining and
using a structure to store student details (name, roll number).
9. Explain the concept of arrays in C. Write a C code snippet to find the sum of elements in
an integer array.
Section C: Long Answer Questions (20 Marks, 10 marks each)
10. Write a C program to implement a stack using an array with operations push, pop, and
display. Explain the logic for each operation.
11. Write a C program to sort an array of integers using the bubble sort algorithm. Provide
the time complexity of the algorithm and explain the sorting process.