Introduction to Programming MCQs with Answers
Practice important Introduction to Programming MCQs with answers and explanations.
Chapter: 21
Q361:
Which operator inverts the bits of its operand?
A. Bitwise OR
B. Bitwise XOR
C. Bitwise AND
D. Bitwise NOT
Correct Answer:
D
Chapter: 21
Q362:
What is the effect of the left shift operator << on a binary number?
A. Multiplies the number by 2
B. Divides the number by 2
C. Adds 1 to the number
D. Subtracts 1 from the number
Correct Answer:
A
Chapter: 21
Q363:
What is the result of 24 >> 1 where 24 in binary is 11000?
A. 11000
B. 1100
C. 110
D. 11
Correct Answer:
B
Chapter: 21
Q364:
What is the result of 12 << 1 where 12 in binary is 1100?
A. 1100
B. 1100
C. 10000
D. 110
Correct Answer:
C
Chapter: 21
Q365:
What does the NOT operator do when applied to the number 8 (1000 in binary)?
A. 111
B. 1000
C. 1111
Correct Answer:
A
Chapter: 21
Q366:
What is a common use case of bit manipulation in operating systems?
A. Setting file attributes
B. Performing arithmetic calculations
C. Sorting data
D. Displaying text
Correct Answer:
A
Chapter: 21
Q367:
How does the XOR operator help in encrypting and decrypting passwords?
A. It converts the password to its original form when applied twice with the same key
B. It stores the password in plain text
C. It changes the password to a readable format
D. It compresses the password
Correct Answer:
A
Chapter: 21
Q368:
What is the result of XORing the binary numbers 1101 and 1011?
A. 110
B. 1110
C. 100
D. 10
Correct Answer:
B
Chapter: 21
Q369:
What does the right shift operator >> do to the binary number?
A. Divides the number by 2
B. Multiplies the number by 2
C. Subtracts 1 from the number
D. Adds 1 to the number
Correct Answer:
A
Chapter: 22
Q370:
What is the compound assignment operator for bitwise AND in C/C++?
A. +=
B. &=
C. &
D. `
Correct Answer:
B
Chapter: 22
Q371:
How is the NOT operation expressed in C/C++?
A. !a
B. ~a
C. ^a
D. &~a
Correct Answer:
B
Chapter: 22
Q372:
Which of the following is not a valid compound assignment operator in C/C++?
A. +=
B. -=
C. *=
D. /=
Correct Answer:
D
Chapter: 22
Q373:
In C/C++, which operator is unary?
A. &
B. ^
C. `
D. ~
Correct Answer:
B
Chapter: 22
Q374:
What is the default parameter passing mechanism in C?
A. Call by reference
B. Call by value
C. Call by address
D. Call by pointer
Correct Answer:
B
Chapter: 22
Q375:
Which of the following is a valid syntax for a while loop in C/C++?
A. while (condition) { // do something }
B. do { // do something } while (condition)
C. for (initialization; condition; increment) { // do something }
D. if (condition) { // do something }
Correct Answer:
A
Chapter: 22
Q376:
What is the role of the break statement in a switch-case structure?
A. It terminates the switch statement execution
B. It continues with the next case
C. It jumps to the start of the switch statement
D. It skips the current case only
Correct Answer:
A
Chapter: 22
Q377:
How does a do-while loop differ from a while loop?
A. It executes the loop body before checking the condition
B. It checks the condition before executing the loop body
C. It only supports single line code blocks
D. It does not support braces
Correct Answer:
A
Chapter: 22
Q378:
Which operator is used to find the remainder of a division in C/C++?
A. +
B. -
C. %
D. /
Correct Answer:
C
Chapter: 22
Q379:
What is the purpose of the continue statement inside a loop?
A. To terminate the loop execution
B. To skip the rest of the loop iteration
C. To exit the current function
D. To exit the loop and move to the next case
Correct Answer:
B
Chapter: 22
Q380:
How are array elements accessed in C/C++?
A. Using 1-based indexing
B. Using 0-based indexing
C. Using negative indexing
D. Using decimal indexing
Correct Answer:
B