0% found this document useful (0 votes)
2 views22 pages

C Programming Questions

The document is a comprehensive C programming question bank that covers various topics including data types, decision making, and looping structures. It contains multiple choice questions, 5-mark questions, and 10-mark questions designed to test knowledge and understanding of C programming concepts. Each section provides questions along with answers, explanations, and practical scenarios to enhance learning.

Uploaded by

Kala Surya
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views22 pages

C Programming Questions

The document is a comprehensive C programming question bank that covers various topics including data types, decision making, and looping structures. It contains multiple choice questions, 5-mark questions, and 10-mark questions designed to test knowledge and understanding of C programming concepts. Each section provides questions along with answers, explanations, and practical scenarios to enhance learning.

Uploaded by

Kala Surya
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

C PROGRAMMING QUESTION BANK

C PROGRAMMING QUESTION BANK

UNIT I: Overview of C and Data Types

Multiple Choice Questions (30 MCQs)


1. Who designed the C programming language?
A) Bjarne Stroustrup
B) Dennis Ritchie
C) Guido van Rossum
D) James Gosling
Answer: B
2. C language was first used in which year?
A) 1970
B) 1971
C) 1972
D) 1973
Answer: C
3. Which of the following is not a C token?
A) Keywords
B) Identifiers
C) Operators
D) Comments
Answer: D
4. How many keywords are in C language?
A) 25
B) 30
C) 32
D) 35
Answer: C
5. Which is a valid identifier in C?
A) 123abc
B) abc-123
C) abc_123
D) abc 123
Answer: C
6. What is the size of int data type on most 32-bit systems?
A) 2 bytes
B) 4 bytes
C) 8 bytes
D) 1 byte
Answer: B
7. Which data type is used to store a single character?
A) int
B) float
C) char
D) string
Answer: C
8. What is the range of values for char data type?
A) 0 to 255

— 1—
C PROGRAMMING QUESTION BANK

B) -128 to 127
C) -256 to 255
D) 0 to 127
Answer: B
9. Which operator is used to assign a value to a variable?
A) ==
B) =
C) :=
D) =>
Answer: B
[Link] will be the value of x after executing: int x = 5; x += 3;
A) 5
B) 3
C) 8
D) 53
Answer: C
[Link] of the following is a floating-point data type?
A) int
B) char
C) double
D) void
Answer: C
[Link] is the output of sizeof(float)?
A) 2 bytes
B) 4 bytes
C) 8 bytes
D) 10 bytes
Answer: B
[Link] many bits are there in 1 byte?
A) 4
B) 6
C) 8
D) 16
Answer: C
[Link] keyword is used to declare a variable that cannot be modified?
A) volatile
B) const
C) final
D) static
Answer: B
[Link] is the correct way to declare a constant in C?
A) constant int x = 10;
B) const int x = 10;
C) final int x = 10;
D) fixed int x = 10;
Answer: B
[Link] variable cannot be modified during program execution?
A) volatile variable
B) static variable
C) const variable
D) automatic variable
Answer: C
[Link] is the scope of a global variable?
A) Only in the function where it is declared

— 2—
C PROGRAMMING QUESTION BANK

B) Only in the block where it is declared


C) Throughout the entire program
D) Only in the current line
Answer: C
[Link] is the initial value of an uninitialized local variable?
A) 0
B) NULL
C) Garbage value
D) Undefined
Answer: C
[Link] of the following is NOT a valid C variable name?
A) _var123
B) var_123
C) var-123
D) VAR123
Answer: C
[Link] is the keyword used to declare a variable that tells the compiler not to
optimize it?
A) const
B) volatile
C) static
D) extern
Answer: B
[Link] many bits are in an int on a typical 32-bit system?
A) 8
B) 16
C) 32
D) 64
Answer: C
[Link] data type is used for very large numbers?
A) int
B) long
C) float
D) char
Answer: B
[Link] is the size of long int on a 32-bit system?
A) 2 bytes
B) 4 bytes
C) 8 bytes
D) 16 bytes
Answer: B
[Link] of the following is a valid constant declaration?
A) const int x;
B) const int x = 10;
C) int const x;
D) Both B and C
Answer: D
[Link] is the escape sequence for newline?
A) \t
B) \n
C) \r
D) \
Answer: B

— 3—
C PROGRAMMING QUESTION BANK

[Link] escape sequence represents a horizontal tab?


A) \n
B) \t
C) \v
D) \b
Answer: B
[Link] is the correct way to assign a string in C?
A) char str = "Hello";
B) char str[] = "Hello";
C) string str = "Hello";
D) char* str = 'Hello';
Answer: B
[Link] of the following declarations is invalid?
A) int x, y, z;
B) int x; int y; int z;
C) int x = 1, y = 2, z = 3;
D) None of the above
Answer: D
[Link] does ASCII stand for?
A) American Standard Code for Information Interchange
B) American System Code for Information
C) American Standard Code for Integer
D) Application Standard Code for Input
Answer: A
[Link] C, the maximum size of an array is limited by:
A) The compiler
B) The operating system
C) Available memory
D) The data type used
Answer: C

5-Mark Questions
[Link] the structure of a C program with its main components. Describe the
purpose of each component and how they contribute to the overall functioning
of a program.
[Link] the terms "token" and "identifier" in C. Provide examples of valid and
invalid identifiers, explaining the rules for naming identifiers in C.
[Link] between constants and variables in C. Provide examples of each
and explain how to declare them properly.
[Link] the different data types available in C and their respective ranges.
Explain when and why each data type would be used in a practical program.
[Link] the difference between the keywords "const" and "volatile" in C.
Provide practical scenarios where each would be used.
[Link] a program to declare variables of different data types and display their
sizes using the sizeof operator. Explain the output you receive.

— 4—
C PROGRAMMING QUESTION BANK

10-Mark Questions
[Link] the complete process of compilation and execution of a C program.
Describe each step involved from source code to executable file and the role of
the compiler in this process.
[Link] the concept of variable declaration and initialization in C. Explain the
difference between declaring and initializing a variable, and demonstrate with
examples how improper initialization can lead to errors.
[Link] the memory representation of different data types in C. Describe how
integers, characters, and floating-point numbers are stored in memory, and
explain why the size of data types varies on different systems.
[Link] the importance of following C naming conventions and character sets
in programming. Discuss how proper use of tokens and identifiers improves
code readability and maintainability.
[Link] and contrast the storage classes in C (automatic, static, extern,
register). Explain how each storage class affects variable lifetime and scope,
and demonstrate practical applications of each.

UNIT II: Decision Making and Looping

Multiple Choice Questions (30 MCQs)


[Link] statement is used to make decisions in C?
A) loop
B) if
C) switch
D) goto
Answer: B
[Link] is the syntax of the if statement?
A) if (condition) { statement; }
B) if condition { statement; }
C) if condition then { statement; }
D) if (condition) statement;
Answer: A
[Link] many else clauses can follow an if statement?
A) 1
B) 2
C) 3
D) Unlimited
Answer: A
[Link] is the purpose of the else-if ladder?
A) To check multiple conditions sequentially
B) To replace multiple if statements
C) To create nested loops
D) To declare multiple variables
Answer: A
[Link] statement is used for multi-way branching?
A) if
B) else-if
C) switch
D) for
Answer: C

— 5—
C PROGRAMMING QUESTION BANK

[Link] a switch statement, what does the break statement do?


A) Stops the program
B) Exits the switch statement
C) Skips the current iteration
D) Continues to the next statement
Answer: B
[Link] is the default case in a switch statement?
A) The first case
B) The last case
C) Executed if no case matches
D) Always executed
Answer: C
[Link] is the output of a switch statement without a break?
A) No output
B) Error
C) Fall-through to next cases
D) Program terminates
Answer: C
[Link] loop is executed at least once regardless of the condition?
A) while loop
B) do-while loop
C) for loop
D) goto loop
Answer: B
[Link] is the syntax of the while loop?
A) while condition { statement; }
B) while (condition) { statement; }
C) while (condition) statement;
D) Both B and C
Answer: D
[Link] loop is most suitable for a known number of iterations?
A) while loop
B) do-while loop
C) for loop
D) goto loop
Answer: C
[Link] is the syntax of the for loop?
A) for (init; condition; increment) { statement; }
B) for condition { statement; }
C) for (init; condition) { statement; }
D) for (statement; condition) { increment; }
Answer: A
[Link] many times will the loop execute: for (i = 0; i < 5; i++) ?
A) 4 times
B) 5 times
C) 6 times
D) Infinite times
Answer: B
[Link] does the continue statement do in a loop?
A) Stops the loop
B) Skips the current iteration
C) Terminates the program
D) Goes to the next line
Answer: B

— 6—
C PROGRAMMING QUESTION BANK

[Link] does the break statement do in a loop?


A) Skips the current iteration
B) Terminates the loop
C) Goes to the next iteration
D) Pauses the loop
Answer: B
[Link] statement is used to transfer control to another part of the program?
A) break
B) continue
C) goto
D) return
Answer: C
[Link] is the output of: if (5 > 3) printf("Yes"); else printf("No");
A) Yes
B) No
C) Both
D) None
Answer: A
[Link] nested if statements be used in C?
A) No
B) Yes
C) Only in functions
D) Only in loops
Answer: B
[Link] is a ternary operator?
A) ? :
B) : ?
C) ?:
D) : :
Answer: A
[Link] does the ternary operator do?
A) Declares variables
B) Returns one of two values based on a condition
C) Creates a loop
D) Defines a function
Answer: B
[Link] a for loop, which part is optional?
A) Initialization
B) Condition
C) Increment
D) All are optional
Answer: D
[Link] is an infinite loop?
A) A loop that runs forever
B) A loop with no condition
C) A loop that doesn't run
D) A loop with multiple conditions
Answer: A
[Link] condition creates an infinite loop: for (;;) ?
A) Increment is missing
B) No condition means it runs forever
C) Initialization is missing
D) All parameters are missing
Answer: B

— 7—
C PROGRAMMING QUESTION BANK

[Link] switch statements be nested?


A) No
B) Yes
C) Only inside loops
D) Only inside functions
Answer: B
[Link] is the default value of the counter in a for loop?
A) 0
B) 1
C) -1
D) Depends on initialization
Answer: D
[Link] many times does this loop execute: while (0) { printf("test"); }
A) 0 times
B) 1 time
C) 2 times
D) Infinite times
Answer: A
[Link] is the output of: for (i = 1; i <= 3; i++) printf("%d", i);
A) 123
B) 012
C) 0123
D) 12
Answer: A
[Link] a do-while loop be nested inside a for loop?
A) No
B) Yes
C) Only in functions
D) Not recommended
Answer: B
[Link] happens if the condition in an if statement is false?
A) The program terminates
B) The else block executes (if present)
C) Nothing happens
D) An error is generated
Answer: B
[Link] a switch statement, the case label must be:
A) A variable
B) A constant or literal value
C) A function call
D) An expression
Answer: B

5-Mark Questions
[Link] the difference between if-else and switch statements. Provide
examples of scenarios where each would be more appropriate to use.
[Link] the working of a do-while loop with an example. Explain why it
executes at least once and how it differs from a while loop.
[Link] a program to find the largest among three numbers using nested if
statements. Explain each decision step in the program.

— 8—
C PROGRAMMING QUESTION BANK

[Link] the purpose of break and continue statements in loops. Provide


examples of how each is used to control loop execution.
[Link] the working of a for loop with all its components. Explain what
happens in each phase of loop execution with a suitable example.
[Link] the concept of nested loops with an example. Demonstrate how to use
nested loops to print a pattern or a multiplication table.

10-Mark Questions
[Link] and contrast while, do-while, and for loops in C. Explain the
execution flow of each loop type and provide examples of scenarios where
each would be most appropriate.
[Link] the concept of decision making in C programming. Discuss the
different types of conditional statements available and demonstrate how to
create complex decision-making structures using nested conditions.
[Link] the working of a switch statement with fall-through behavior. Explain
when fall-through is useful and how to prevent unwanted fall-through using
break statements.
[Link] a program to validate user input using appropriate decision-making
constructs. Explain the logic used and how to handle invalid inputs gracefully.
[Link] the concept of jumping statements (break, continue, goto) in C.
Discuss the proper use of these statements and provide examples of their
applications in loops and switch statements.

UNIT III: Arrays

Multiple Choice Questions (30 MCQs)


[Link] is an array in C?
A) A single variable that holds multiple values
B) A collection of values of the same data type stored in contiguous memory
C) A special data type in C
D) A function that returns multiple values
Answer: B
[Link] do you declare a one-dimensional array in C?
A) int array;
B) int array[10];
C) array[10] int;
D) int 10 array;
Answer: B
[Link] is the index of the first element in an array?
A) 0
B) 1
C) -1
D) It depends on the declaration
Answer: A
[Link] an array is declared as int arr[5], what is the size of the array?
A) 4
B) 5

— 9—
C PROGRAMMING QUESTION BANK

C) 6
D) 10
Answer: B
[Link] do you initialize an array with values in C?
A) int arr[3] = 1, 2, 3;
B) int arr[3] = {1, 2, 3};
C) int arr[] {1, 2, 3};
D) int arr[3] <- 1, 2, 3;
Answer: B
[Link] will be the value of arr[2] for int arr[] = {10, 20, 30, 40};
A) 10
B) 20
C) 30
D) 40
Answer: C
[Link] is a two-dimensional array?
A) An array with two elements
B) An array of arrays
C) An array with two values
D) A matrix with two rows
Answer: B
[Link] do you declare a two-dimensional array in C?
A) int arr[3][4];
B) int arr[3,4];
C) int arr[3:4];
D) int arr(3,4);
Answer: A
[Link] a two-dimensional array int arr[3][4], how many elements are there?
A) 3
B) 4
C) 7
D) 12
Answer: D
[Link] do you access an element in a two-dimensional array?
A) arr[i,j]
B) arr[i][j]
C) arr(i,j)
D) arr{i,j}
Answer: B
[Link] is the address of arr[0] if arr is an array?
A) A random address
B) The base address of the array
C) The address of the first element
D) Both B and C
Answer: D
[Link] you change the size of an array after declaration?
A) Yes, using resize function
B) No, arrays have fixed size
C) Yes, using malloc
D) Yes, using realloc
Answer: B
[Link] happens if you access an array element beyond its size?
A) Error message
B) Program terminates

— 10 —
C PROGRAMMING QUESTION BANK

C) Undefined behavior
D) Returns 0
Answer: C
[Link] do you find the number of elements in an array int arr[10]?
A) length(arr)
B) size(arr)
C) sizeof(arr)/sizeof(arr[0])
D) [Link]()
Answer: C
[Link] is the output of sizeof(arr) for int arr[10]?
A) 10
B) 20
C) 40
D) 50
Answer: C
[Link] strings be stored in a character array?
A) No
B) Yes
C) Only single characters
D) Only using string functions
Answer: B
[Link] do you declare a character array to store a string?
A) char str[20];
B) char str = 20;
C) string str[20];
D) char 20 str;
Answer: A
100. What is a multi-dimensional array?
A) An array with multiple dimensions
B) An array inside another array
C) An array with more than two dimensions
D) All of the above
Answer: D
101. How do you initialize a two-dimensional array?
A) int arr[2][3] = 1,2,3,4,5,6;
B) int arr[2][3] = {{1,2,3},{4,5,6}};
C) int arr[2][3] = {1,2,3,4,5,6};
D) Both B and C
Answer: D
102. What is the first element of array int arr[3][3] = {{1,2,3},{4,5,6},
{7,8,9}};
A) 1
B) 4
C) 7
D) 0
Answer: A
103. In a two-dimensional array, how is data stored in memory?
A) Row-wise
B) Column-wise
C) Random order
D) Depends on the compiler
Answer: A
104. What is the index of the last element in int arr[5]?
A) 5

— 11 —
C PROGRAMMING QUESTION BANK

B) 4
C) 0
D) Undefined
Answer: B
105. Can you have an array of arrays in C?
A) No
B) Yes, it's a multi-dimensional array
C) Only in C++
D) Not recommended
Answer: B
106. What is the output of: int arr[3]; arr[5] = 10;
A) Compilation error
B) Runtime error
C) Undefined behavior
D) Value assigned successfully
Answer: C
107. How many dimensions can an array have in C?
A) Maximum 2
B) Maximum 3
C) No theoretical limit
D) Maximum 10
Answer: C
108. What is an uninitialized array?
A) An array with garbage values
B) An array with all zeros
C) An array with all ones
D) An array with NULL values
Answer: A
109. Can you partially initialize an array in C?
A) No
B) Yes, remaining elements are set to 0
C) Yes, remaining elements are set to garbage
D) Depends on the data type
Answer: B
110. What is the size of char arr[10][20]?
A) 30 bytes
B) 200 bytes
C) 100 bytes
D) Depends on the system
Answer: B
111. In a multi-dimensional array, which index varies the fastest in memory?
A) First index
B) Last index
C) Middle index
D) All vary equally
Answer: B
112. What does arr[i][j] represent in a 2D array?
A) Value at row i, column j
B) Value at column i, row j
C) ith element of jth array
D) Both A and C
Answer: A

— 12 —
C PROGRAMMING QUESTION BANK

5-Mark Questions
113. Explain the concept of one-dimensional arrays in C. Describe how to
declare, initialize, and access array elements. Provide an example program
that demonstrates array usage.
114. Describe the structure and usage of two-dimensional arrays. Explain
how data is stored in memory in row-major order and provide an example of
initializing and accessing elements.
115. Write a program to read 5 numbers into an array, find the sum and
average, and display the results. Explain each step of the program.
116. Explain the concept of multi-dimensional arrays in C. Provide examples
of three-dimensional arrays and explain how memory allocation works for such
arrays.
117. Describe the relationship between arrays and pointers in C. Explain how
array names represent base addresses and how this relationship facilitates
array operations.
118. Write a program to read a matrix of size 3x3 and display it. Explain how
nested loops are used to access each element of the two-dimensional array.

10-Mark Questions
119. Analyze the memory representation and allocation of one-dimensional
and two-dimensional arrays in C. Explain row-major and column-major ordering
and demonstrate how memory addresses are calculated for multi-dimensional
arrays.
120. Design a program to perform matrix operations like addition and
multiplication of two 2D arrays. Explain the logic used in each operation and
demonstrate with examples.
121. Explain the advantages and disadvantages of using arrays in C
programming. Discuss when arrays are appropriate and when dynamic
memory allocation might be better. Provide practical examples.
122. Describe the concept of ragged arrays and how they differ from regular
multi-dimensional arrays. Explain how to implement and use ragged arrays in
C with appropriate examples.
123. Design a comprehensive program that demonstrates the use of both
one-dimensional and two-dimensional arrays. Include operations like
searching, sorting, and transforming array data.

UNIT IV: Functions

Multiple Choice Questions (30 MCQs)


124. What is a function in C?
A) A block of code that performs a specific task
B) A variable that stores a value
C) A data structure
D) A loop construct
Answer: A

— 13 —
C PROGRAMMING QUESTION BANK

125. What is the syntax of a function definition?


A) return_type function_name() { statements; }
B) function_name return_type() { statements; }
C) return_type () function_name { statements; }
D) function_name() return_type { statements; }
Answer: A
126. What does a return statement do in a function?
A) Stops the function execution
B) Sends a value back to the caller
C) Terminates the program
D) Both A and B
Answer: D
127. What is the return type of a function that doesn't return any value?
A) int
B) void
C) null
D) none
Answer: B
128. How many return statements can a function have?
A) Only 1
B) Only 2
C) Multiple, but only one will execute
D) No limit
Answer: C
129. What is a function prototype?
A) The implementation of a function
B) A declaration that tells the compiler about the function
C) The main function
D) A function inside another function
Answer: B
130. What is the correct syntax for a function prototype?
A) return_type function_name(parameters);
B) function_name return_type (parameters);
C) return_type (parameters) function_name;
D) parameters return_type function_name();
Answer: A
131. What is call by value in C?
A) Passing the address of a variable
B) Passing a copy of the variable's value
C) Passing the reference of a variable
D) Passing the variable name
Answer: B
132. What is call by reference in C?
A) Passing the value of a variable
B) Passing a copy of the variable
C) Passing the address of a variable
D) Passing the pointer to the variable's data type
Answer: C
133. In call by value, if the parameter is modified inside the function, what
happens to the original variable?
A) It gets modified
B) It remains unchanged
C) It becomes NULL
D) It causes an error
Answer: B

— 14 —
C PROGRAMMING QUESTION BANK

134. In call by reference, if the parameter is modified inside the function,


what happens to the original variable?
A) It gets modified
B) It remains unchanged
C) It becomes NULL
D) It causes an error
Answer: A
135. What is recursion in C?
A) Calling a function multiple times
B) A function calling itself
C) Nested function calls
D) Calling different functions in sequence
Answer: B
136. What is a base case in recursion?
A) The first call to a function
B) The condition that stops recursion
C) The last function call
D) A case inside an if statement
Answer: B
137. What happens if a recursive function has no base case?
A) Infinite recursion
B) Stack overflow
C) Program terminates
D) Both A and B
Answer: D
138. What is a nested function?
A) A function inside another function
B) Multiple functions with the same name
C) A function that calls itself
D) A function with nested loops
Answer: A
139. Are nested functions allowed in C?
A) Yes, always
B) No, C doesn't support nested functions
C) Only in some compilers
D) Only in functions with void return type
Answer: B
140. What is a storage class in C?
A) A type of array
B) An attribute that determines the scope and lifetime of a variable
C) A function category
D) A data structure
Answer: B
141. How many storage classes are there in C?
A) 2
B) 3
C) 4
D) 5
Answer: C
142. What is the automatic storage class?
A) Variables with global scope
B) Variables declared inside a function
C) Variables that are static
D) Variables with external linkage
Answer: B

— 15 —
C PROGRAMMING QUESTION BANK

143. What is the scope of a static variable?


A) Only in the block where it's declared
B) Throughout the program
C) Only in the function where it's declared
D) Only visible to the current file
Answer: C
144. What is the purpose of the extern keyword?
A) To declare a variable with local scope
B) To declare a variable with global scope
C) To declare a variable defined in another file
D) To declare a constant variable
Answer: C
145. What is the register storage class used for?
A) Storing variables in the register (CPU memory)
B) Storing variables in the main memory
C) Declaring global variables
D) Declaring function parameters
Answer: A
146. What is an array of strings in C?
A) An array of characters
B) A two-dimensional array of characters
C) Multiple string variables
D) A structure containing strings
Answer: B
147. How do you pass an array to a function in C?
A) Pass the entire array
B) Pass the base address (name of the array)
C) Pass each element individually
D) Arrays cannot be passed to functions
Answer: B
148. What happens when an array is passed to a function?
A) The entire array is copied
B) Only the base address is passed
C) Each element is individually copied
D) The array becomes global
Answer: B
149. What is the output of a function with no return statement?
A) 0
B) NULL
C) Undefined
D) An error message
Answer: C
150. Can a function return multiple values in C?
A) Yes, using arrays
B) Yes, using pointers
C) Yes, using structures
D) No, only one value can be returned
Answer: A
151. What are built-in functions in C?
A) Functions defined by the user
B) Functions provided by the C library
C) Functions used in mathematical operations
D) Functions with no return type
Answer: B

— 16 —
C PROGRAMMING QUESTION BANK

152. What is the difference between a function and a procedure?


A) No difference
B) A function returns a value, a procedure doesn't
C) A function is faster
D) A procedure is used only for printing
Answer: B
153. What is the maximum number of parameters a function can have in C?
A) 5
B) 10
C) No fixed limit
D) Depends on the compiler
Answer: C

5-Mark Questions
154. Explain the structure of a function in C with all its components. Describe
function declaration, definition, and calling with an example program.
155. Describe the difference between call by value and call by reference in C.
Provide examples of both methods and explain when each is appropriate to
use.
156. Write a program to demonstrate recursion by calculating the factorial of
a number. Explain how the recursive calls and base case work in this example.
157. Explain the concept of storage classes in C. Describe the different
storage classes available and their scope, lifetime, and default values.
158. Describe how arrays are passed to functions in C. Explain why arrays
are always passed by reference and provide an example of a function that
processes an array.
159. Write a program demonstrating the use of strings and string handling
functions. Explain how strings are stored as character arrays and manipulated
in C.

10-Mark Questions
160. Analyze the complete process of function calling and execution in C.
Explain the function call stack, parameter passing mechanisms, and how
return values are handled.
161. Compare and contrast call by value and call by reference in C
programming. Explain the advantages and disadvantages of each method with
practical examples where each is more appropriate.
162. Explain the concept of recursion in detail. Discuss how recursive
functions work, the importance of base cases, and the relationship between
recursion and iteration.
163. Design a program that demonstrates the use of multiple functions
working together. Include examples of different parameter passing methods
and return types.
164. Analyze the storage classes in C programming. Explain how each
storage class affects variable scope, lifetime, and default initialization. Provide
practical examples of when each is used.

— 17 —
C PROGRAMMING QUESTION BANK

UNIT V: Pointers

Multiple Choice Questions (30 MCQs)


165. What is a pointer in C?
A) A variable that stores an address
B) A variable that stores a value
C) A function that returns values
D) A data structure for storing multiple values
Answer: A
166. What is the address-of operator in C?
A) *
B) &
C) ->
D) .
Answer: B
167. What is the dereference operator in C?
A) *
B) &
C) ->
D) .
Answer: A
168. How do you declare a pointer to an integer?
A) int ptr;
B) int& ptr;
C) int ptr;
D) *int ptr;
Answer: A
169. What is the output of: int x = 10; int *ptr = &x; printf("%d", *ptr);
A) Address of x
B) 10
C) ptr
D) &x
Answer: B
170. What does NULL represent in pointers?
A) An uninitialized pointer
B) A pointer that points to nothing
C) A pointer with address 0
D) Both B and C
Answer: D
171. What is the size of a pointer in bytes on a 32-bit system?
A) 1 byte
B) 2 bytes
C) 4 bytes
D) 8 bytes
Answer: C
172. What is the size of a pointer in bytes on a 64-bit system?
A) 4 bytes
B) 8 bytes
C) 16 bytes

— 18 —
C PROGRAMMING QUESTION BANK

D) 32 bytes
Answer: B
173. What is a void pointer?
A) A pointer with no data type
B) A pointer that can point to any data type
C) A null pointer
D) Both A and B
Answer: B
174. How do you typecast a void pointer?
A) (int) void_ptr;
B) (int*) void_ptr;
C) void_ptr (int);
D) (int) *void_ptr;
Answer: B
175. What is pointer arithmetic?
A) Mathematical operations on pointers
B) Operations on the values pointed by pointers
C) Incrementing or decrementing pointer addresses
D) All of the above
Answer: C
176. What is the result of ptr++ for a pointer to an integer?
A) Increments by 1 byte
B) Increments by the size of the data type (4 bytes for int)
C) Causes an error
D) Increments by the size of the pointer
Answer: B
177. What is a pointer to a pointer?
A) A pointer that points to another pointer
B) A pointer that points to itself
C) Multiple pointers
D) A reference to a pointer
Answer: A
178. How do you declare a pointer to a pointer?
A) int **ptr;
B) int ptr;
C) int ptr;
D) int *&ptr;
Answer: A
179. What is the relationship between arrays and pointers?
A) Arrays and pointers are the same thing
B) Array names are pointers to the first element
C) Arrays can be used wherever pointers are used
D) Both B and C
Answer: D
180. What is the output of: int arr[5]; printf("%p", arr);
A) Address of the first element
B) Address of the last element
C) Size of the array
D) Number of elements
Answer: A
181. How do you access an array element using pointer notation?
A) *ptr[i]
B) *(ptr + i)
C) ptr[i]

— 19 —
C PROGRAMMING QUESTION BANK

D) All of the above


Answer: D
182. What is a function pointer?
A) A pointer to a function
B) A function that returns a pointer
C) A pointer inside a function
D) A function that takes a pointer as argument
Answer: A
183. How do you declare a function pointer?
A) int *func();
B) int (*func)();
C) int (*func)();
D) Both B and C
Answer: C
184. What is the purpose of a function pointer?
A) To call functions dynamically
B) To pass functions as arguments
C) To create arrays of functions
D) All of the above
Answer: D
185. What is dynamic memory allocation?
A) Allocating memory at compile time
B) Allocating memory at runtime
C) Allocating memory on the stack
D) Allocating memory for functions
Answer: B
186. What is the purpose of the malloc function?
A) To allocate memory on the heap
B) To deallocate memory
C) To initialize memory
D) To get the size of allocated memory
Answer: A
187. What is the syntax of malloc?
A) malloc(size);
B) malloc (data_type size);
C) malloc (number_of_bytes);
D) Both A and C
Answer: D
188. What does malloc return?
A) An integer representing the address
B) A void pointer to the allocated memory
C) The size of allocated memory
D) A pointer to the data type
Answer: B
189. What is the purpose of the free function?
A) To allocate memory
B) To deallocate memory
C) To check memory availability
D) To copy memory
Answer: B
190. What happens if you don't free allocated memory?
A) It causes an error
B) It is automatically freed
C) Memory leak occurs

— 20 —
C PROGRAMMING QUESTION BANK

D) The program terminates


Answer: C
191. What is the difference between a pointer and a reference?
A) No difference
B) References cannot be NULL, pointers can
C) References are used for functions, pointers for variables
D) References are automatic, pointers are manual
Answer: B
192. What is a structure pointer?
A) A pointer to a structure
B) A structure containing pointers
C) A structure with pointer members
D) All of the above
Answer: A
193. What is the arrow operator (->) used for?
A) To access structure members through a pointer
B) To define a function
C) To access array elements
D) To compare values
Answer: A
194. What is the relationship between pointers and strings in C?
A) Strings are arrays of pointers
B) Strings are pointer to characters
C) Strings can be represented using pointers
D) Pointers are used to manipulate strings
Answer: D

5-Mark Questions
195. Explain the concept of pointers in C with examples. Describe how to
declare, initialize, and use pointers. Demonstrate pointer notation with a
simple program.
196. Describe pointer arithmetic in C. Explain how incrementing and
decrementing pointers works, especially in relation to the data type they point
to.
197. Explain the relationship between arrays and pointers in C. Demonstrate
how array elements can be accessed using pointer notation and array
indexing.
198. Describe dynamic memory allocation in C. Explain the purpose and
usage of malloc and free functions with examples of allocating and
deallocating memory.
199. Write a program to demonstrate the use of pointers with functions.
Include examples of passing pointers as arguments and returning pointers
from functions.
200. Explain the concept of function pointers in C. Demonstrate how function
pointers can be used to call different functions dynamically.

— 21 —
C PROGRAMMING QUESTION BANK

10-Mark Questions
201. Analyze the complete memory model of C programming with emphasis
on pointers. Explain stack memory, heap memory, and how pointers facilitate
access to both. Discuss the relationship between memory addresses and
pointer values.
202. Design a comprehensive program that demonstrates multiple pointer
concepts including pointer arithmetic, pointers to arrays, pointers to functions,
and dynamic memory allocation.
203. Explain the concept of dynamic memory allocation and deallocation in
C. Compare static and dynamic allocation, discuss memory leaks, and provide
strategies to manage heap memory effectively.
204. Describe advanced pointer concepts including pointers to pointers,
function pointers, and pointers in structures. Provide practical examples of
where and why these advanced pointer techniques are used.
205. Analyze the relationship between strings and pointers in C. Explain how
strings are stored, accessed, and manipulated using pointers, and
demonstrate string operations using pointer techniques.

END OF QUESTION BANK

— 22 —

You might also like