Skip to main content

Introduction to Programming MCQs with Answers

Practice important Introduction to Programming MCQs with answers and explanations.

Multiple Choice Questions

Q201: How should you pass a two-dimensional array to a function in C++?
  • A: Only specify the array name
  • B: Specify the array name and the number of rows
  • C: Specify the array name and the number of columns
  • D: Only specify the number of rows
View Answer
C

Q202: What is a key consideration when implementing the findUnluckies function?
  • A: Ensure it operates in constant time
  • B: Ensure it correctly identifies employees with lesser take-home pay
  • C: Ensure it handles large arrays efficiently
  • D: Ensure it only processes the top salaries
View Answer
B

Q203: Why might a global variable be used in the salary calculation program?
  • A: To avoid passing variables between functions
  • B: To store intermediate calculation results
  • C: To keep track of the number of employees globally
  • D: To simplify the function implementations
View Answer
A

Q204: What is the purpose of initializing the lucky array to zero?
  • A: To mark all employees as unlucky initially
  • B: To mark all employees as lucky initially
  • C: To avoid accessing uninitialized elements
  • D: To ensure all elements are zeroed before processing
View Answer
C

Q205: What does a pointer store in C++?
  • A: The value of a variable
  • B: The memory address of a variable
  • C: The data type of a variable
  • D: The name of a variable
View Answer
B

Q206: What is the purpose of the address operator (&) in C++?
  • A: To obtain the memory address of a variable
  • B: To obtain the value stored in a variable
  • C: To declare a pointer
  • D: To perform a logical AND operation
View Answer
A

Q207: How do you declare a pointer to an integer in C++?
  • A: int *ptr
  • B: int ptr*
  • C: int ptr
  • D: int * ptr
View Answer
A

Q208: What does *ptr represent when ptr is a pointer variable?
  • A: The address of ptr
  • B: The value stored at the memory location pointed to by ptr
  • C: The type of data ptr points to
  • D: The size of the memory location pointed to by ptr
View Answer
B

Q209: What will be the result of the statement *ptr = 10; if ptr is a pointer to an integer?
  • A: The value 10 is stored at the memory location ptr points to
  • B: The address of the memory location pointed to by ptr
  • C: The value of ptr is set to 10
  • D: The pointer ptr is assigned a new address
View Answer
A

Q210: What is the output of *ptr + 2 where *ptr is 10?
  • A: 8
  • B: 10
  • C: 12
  • D: 14
View Answer
C

Test Your Knowledge

Take a timed quiz on Introduction to Programming

🚀 Start Quiz Now