Skip to main content

Introduction to Programming MCQs with Answers

Practice important Introduction to Programming MCQs with answers and explanations.

Multiple Choice Questions

Q341: In the sample program, how is the maximum GPA determined?
  • A: By comparing GPA values during input
  • B: By finding the highest GPA in the array after input
  • C: By using the GPA value of the last student
  • D: By calculating the average GPA
View Answer
B

Q342: What will the output be if the average GPA is 3.5 in the sample program?
  • A: The average Grade of the class is A
  • B: The average Grade of the class is B
  • C: The average Grade of the class is C
  • D: The average Grade of the class is F
View Answer
B

Q343: In the file handling sample program, what function is used to read data from a file and return a structure?
  • A: writeData()
  • B: openFile()
  • C: getData()
  • D: writeData()
View Answer
C

Q344: How does the union intOrChar handle memory?
  • A: Each member has its own memory space
  • B: All members share the same memory space
  • C: It uses twice the memory of the largest member
  • D: It uses half the memory of the largest member
View Answer
B

Q345: What is the size of the union intOrDouble?
  • A: Equal to the size of int
  • B: Equal to the size of double
  • C: Equal to the combined size of int and double
  • D: Depends on the system architecture
View Answer
B

Q346: In the union example, what happens when you assign 'a' to the integer member and then access the character array?
  • A: The character array shows 'a' and the integer value shows the ASCII code of 'a'
  • B: The character array shows 'a' in all positions
  • C: The integer value shows the ASCII code of 'a'
  • D: The character array shows 'a' and 'b'
View Answer
A

Q347: How is the file opened in the sample program for input and output?
  • A: Using ifstream and ofstream
  • B: Using fstream only
  • C: Using ifstream only
  • D: Using ofstream only
View Answer
A

Q348: In the union example, what will be the output of the integer value after multiple shifts and additions?
  • A: It will show the concatenated result of all characters
  • B: It will show only the last character added
  • C: It will show the sum of all characters' ASCII codes
  • D: It will show the ASCII code of the first character
View Answer
A

Q349: What function is used to write a student structure to a file?
  • A: getData()
  • B: openFile()
  • C: writeData()
  • D: readData()
View Answer
C

Q350: What is the purpose of the sizeof operator when used with structures?
  • A: To determine the number of members
  • B: To find the size of each data member
  • C: To find the total memory occupied by the structure
  • D: To count the number of elements in the structure
View Answer
C

Test Your Knowledge

Take a timed quiz on Introduction to Programming

🚀 Start Quiz Now