Skip to main content

Introduction to Programming MCQs with Answers

Practice important Introduction to Programming MCQs with answers and explanations.

Multiple Choice Questions

Q221: What does the array name 'y' represent in C?
  • A: A) A pointer to the first element
  • B: B) The size of the array
  • C: C) A constant pointer to the array’s memory address
  • D: D) A variable storing the array's length
View Answer
C

Q222: What happens when you increment a pointer variable in C?
  • A: A) It moves to the next memory location of the same data type
  • B: B) It moves to the next integer location in memory
  • C: C) It increments by one byte irrespective of the data type
  • D: D) It increments by four bytes always
View Answer
A

Q223: Which of the following statements is true about pointer arithmetic?
  • A: A) Adding two pointers is allowed in C
  • B: B) Subtracting two pointers gives the number of bytes between them
  • C: C) Incrementing a pointer by 1 always increments it by 1 byte
  • D: D) Subtracting pointers gives the number of elements between them
View Answer
D

Q224: How is the null character used in a C string?
  • A: A) To signify the end of a string
  • B: B) To indicate the start of a string
  • C: C) To separate strings in a character array
  • D: D) To initialize an array of characters
View Answer
A

Q225: What is the result of the following pointer subtraction operation: yptr2 - yptr1 where yptr1 points to y[0] and yptr2 points to y[3]?
  • A: A) 3
  • B: B) 12
  • C: C) 4
  • D: D) 1
View Answer
A

Q226: Which of the following correctly increments the value pointed to by a pointer?
  • A: A) (*ptr)++
  • B: B) ptr++
  • C: C) ++(*ptr)
  • D: D) Both A and C
View Answer
D

Q227: What will be the output of the following code snippet?
  • A: A) 10
  • B: B) 11
  • C: C) 12
  • D: D) Compilation error
View Answer
B

Q228: In the context of pointer and array relationship, what is true about the statement yptr = y?
  • A: A) yptr can be assigned to any memory address
  • B: B) yptr is assigned the address of the first element of the array y
  • C: C) yptr is a constant pointer
  • D: D) y can be reassigned to point to a different memory address
View Answer
B

Q229: What does the expression *(yptr + 5) do if yptr is a pointer to the beginning of an integer array?
  • A: A) Accesses the fifth element in the array
  • B: B) Increments the value of yptr by 5
  • C: C) Assigns the value 5 to yptr
  • D: D) Accesses the value of the sixth element in the array
View Answer
A

Q230: How does pointer comparison work in C?
  • A: A) Pointers can only be compared if they point to the same data type
  • B: B) Pointers can be compared to determine their relative addresses
  • C: C) You cannot compare pointers directly; you need to dereference them first
  • D: D) Pointers can be compared only if they point to the same array
View Answer
B

Test Your Knowledge

Take a timed quiz on Introduction to Programming

🚀 Start Quiz Now