T4Tutorials .PK

VU Past Papers CS201-Most Importants MCQs on Operators and Programming Constructs in C/C++

Q#1: What is the purpose of compound assignment operators in C/C++?
(A) Simplifying bitwise operations
(B) Incrementing variables
(C) Combining logical operators
(D) Enhancing arithmetic operations
Answer: (D) Enhancing arithmetic operations

Q#2: How is the bitwise AND operation (a = a & b) written using compound assignment?
(A) a = a && b;
(B) a &= b;
(C) a = a || b;
(D) a == b;
Answer: (B) a &= b;

Q#3: Which operator is NOT a compound assignment operator?
(A) &=
(B) |=
(C) ~=
(D) ^=
Answer: (C) ~=

Q#4: According to the paragraph, what is the purpose of the ~ (NOT) operator?
(A) Bitwise AND
(B) Bitwise OR
(C) Bitwise inversion or NOT
(D) Unary increment
Answer: (C) Bitwise inversion or NOT

Q#5: In the Design Recipe, what is the main heading emphasized for programmers?
(A) Test Cases
(B) Pay attention to the detail
(C) Problem Analysis
(D) Code Implementation
Answer: (B) Pay attention to the detail

Q#6: How is the yearly net salary calculation process described in the Design Recipe?
(A) Analyzing the problem
(B) Expressing in words
(C) Writing the program
(D) Testing the solution
Answer: (B) Expressing in words

Q#7: What are variables in C/C++?
(A) Hard-coded memory addresses
(B) Mechanisms to manipulate memory
(C) Numeric values
(D) Unary operators
Answer: (B) Mechanisms to manipulate memory

Q#8: According to the paragraph, what is the int data type used for?
(A) Real numbers
(B) Characters
(C) Whole numbers
(D) Non-negative numbers
Answer: (C) Whole numbers

Q#9: What is the size of the char data type in the paragraph’s context?
(A) 2 bytes
(B) 4 bytes
(C) 1 byte
(D) 8 bytes
Answer: (C) 1 byte

Q#10: How are compound arithmetic operators written in C/C++?
(A) +=, -=, *=, /=
(B) ++, —
(C) &&, ||
(D) ==, !=
Answer: (A) +=, -=, *=, /=

Q#11: What is the modulus operator (%) used for in the paragraph?
(A) Division
(B) Multiplication
(C) Addition
(D) Remainder
Answer: (D) Remainder

Q#12: What is the primary purpose of logical operators in C/C++?
(A) Arithmetic calculations
(B) Comparison of two numbers
(C) Bitwise manipulations
(D) Assignment operations
Answer: (B) Comparison of two numbers

Q#13: How is the logical AND operator written in C/C++?
(A) &
(B) &&
(C) ||
(D) AND
Answer: (B) &&

Q#14: What caution is mentioned regarding the assignment statement (a = b) in the paragraph?
(A) Avoid using it
(B) Use it for bitwise operations only
(C) Be careful with logical comparisons
(D) It has no value
Answer: (C) Be careful with logical comparisons

Q#15: In the context of comparisons, what does the == operator represent?
(A) Equality
(B) Assignment
(C) Addition
(D) Modulus
Answer: (A) Equality

Q#16: What type of operators are bitwise AND, OR, and XOR?
(A) Unary operators
(B) Binary operators
(C) Ternary operators
(D) Logical operators
Answer: (B) Binary operators

Q#17: How is the bitwise NOT operator (~) described in the paragraph?
(A) Unary
(B) Binary
(C) Ternary
(D) Logical
Answer: (A) Unary

Q#18: What is NOT a part of programming constructs discussed in the paragraph?
(A) Sequential execution
(B) Decisions
(C) File I/O
(D) Loops
Answer: (C) File I/O

Q#19: Which construct is used for repetitive structures in programming?
(A) Sequential execution
(B) Decisions
(C) File I/O
(D) Loops
Answer: (D) Loops

Q#20: What is the syntax of the if statement?
(A) if (condition) { /* code block / }
(B) if { /
code block / } (condition)
(C) { /
code block / } if (condition)
(D) condition { /
code block / }
Answer: (A) if (condition) { /
code block */ }

Exit mobile version