Skip to main content

Introduction to Programming MCQs with Answers

Practice important Introduction to Programming MCQs with answers and explanations.

Multiple Choice Questions

Q151: How is a global variable different from a local variable in terms of scope?
  • A: Global variables are only visible within a function
  • B: Local variables are visible in the entire program
  • C: Global variables are visible in all functions
  • D: Local variables are visible in all functions
View Answer
C

Q152: void func() { int i; { int i = 10; } } What is the scope of the inner i?
  • A: Function level
  • B: Block level
  • C: Global level
  • D: Local level
View Answer
B

Q153: What does the following code snippet demonstrate?
  • A: void square(double x) { x = x * x; }
  • B: Passing by reference
  • C: Passing by value
  • D: Memory allocation
View Answer
B

Q154: In the Call by Value mechanism, what is passed to the function?
  • A: The actual value of the variable
  • B: The address of the variable
  • C: A copy of the value of the variable
  • D: The variable’s name
View Answer
C

Q155: Why might you use Call by Reference instead of Call by Value?
  • A: To improve code readability
  • B: To avoid copying large data
  • C: To prevent the function from modifying data
  • D: To pass data in a more compact form
View Answer
B

Q156: What is the result of passing the address of a variable to a function?
  • A: The function creates a copy of the variable
  • B: The function modifies the original variable
  • C: The function receives a reference to the variable
  • D: The function creates a new variable
View Answer
C

Q157: Which of the following is NOT a feature of recursion?
  • A: Elegance of code
  • B: Memory efficiency
  • C: A base case that terminates the recursion
  • D: Potential for stack overflow
View Answer
B

Q158: What will be the output of the following recursive function?
  • A: long fact(long n) { if (n <= 1) return 1; else return n * fact(n-1); }
  • B: 120
  • C: 720
  • D: 1
View Answer
B

Q159: In C, which library provides mathematical functions such as square root and logarithms?
  • A:
  • B:
  • C:
  • D:
View Answer
A

Q160: What is the primary purpose of using arrays in C?
  • A: To store a collection of data of different types
  • B: To store a collection of data of the same type
  • C: To enhance program performance
  • D: To decrease memory usage
View Answer
B

Test Your Knowledge

Take a timed quiz on Introduction to Programming

🚀 Start Quiz Now