Skip to main content

Introduction to Programming MCQs with Answers

Practice important Introduction to Programming MCQs with answers and explanations.

Multiple Choice Questions

Q331: What is the primary purpose of using a structure in C/C++?
  • A: To group related data together
  • B: To store data as a single integer
  • C: To perform mathematical operations
  • D: To execute a series of functions
View Answer
A

Q332: How do you access a structure’s member using a pointer to the structure?
  • A: (*ptr).member
  • B: ptr->member
  • C: ptr.member
  • D: (*ptr->member)
View Answer
B

Q333: Which of the following is true about structures in C/C++?
  • A: Structures cannot contain other structures
  • B: Structures can only contain pointers
  • C: Structures can contain other structures
  • D: Structures are not extensible
View Answer
C

Q334: Can you directly perform arithmetic operations on structures in C/C++?
  • A: Yes, using standard arithmetic operators
  • B: No, structures cannot be directly added
  • C: Yes, but only with integer structures
  • D: Yes, with custom operator overloading
View Answer
B

Q335: What is the output of s1.age = 20; if s1 is a variable of type struct student?
  • A: It updates the age member of s1
  • B: It creates a new structure s1
  • C: It initializes s1 to age 20
  • D: It has no effect on s1
View Answer
A

Q336: What operator is used to access members of a structure through a pointer?
  • A: *
  • B: ->
  • C: .
  • D: &
View Answer
B

Q337: What does the sizeof operator return when applied to a structure?
  • A: The number of members in the structure
  • B: The total number of bytes the structure occupies
  • C: The size of the largest data member
  • D: The number of elements in the array
View Answer
B

Q338: What will be the output of sizeof(s1) if s1 is a structure containing two char arrays and two int data types?
  • A: Depends on the implementation
  • B: 64 bytes
  • C: 128 bytes
  • D: 200 bytes
View Answer
D

Q339: What is the correct way to access the name of the first student in an array of structures named s?
  • A: s[1].name
  • B: s[0].name
  • C: s.name[0]
  • D: s.name[1]
View Answer
B

Q340: Which operator is used to access members of a structure using a pointer?
  • A: *
  • B: ->
  • C: .
  • D: &
View Answer
B

Test Your Knowledge

Take a timed quiz on Introduction to Programming

🚀 Start Quiz Now