C - Operators Practice Test.1

  1. What is the purpose of arithmetic operators in C?

    A) To perform mathematical calculations on numeric data

    B) To compare two values and return a Boolean result

    C) To control the flow of program execution

    D) To print output to the console

    Answer: A) To perform mathematical calculations on numeric data

  2. Which operator is used for addition in C?

    A) + (Plus)

    B) - (Minus)

    C) * (Multiplication)

    D) / (Division)

    Answer: A) + (Plus)

  3. What will be the result of the expression `5 - 3` using subtraction operator?

    A) 2

    B) 8

    C) 15

    D) 0

    Answer: A) 2

  4. Which operator is used for multiplication in C?

    A) + (Plus)

    B) - (Minus)

    C) * (Multiplication)

    D) / (Division)

    Answer: C) * (Multiplication)

  5. What will be the result of the expression `10 / 2` using division operator?

    A) 5

    B) 8

    C) 2.5

    D) 0

    Answer: A) 5

  6. Which operator is used for finding the remainder in C?

    A) % (Modulus)

    B) / (Division)

    C) * (Multiplication)

    D) + (Plus)

    Answer: A) % (Modulus)

  7. What will be the result of the expression `15 % 4` using modulus operator?

    A) 3

    B) 0

    C) 4

    D) 1

    Answer: A) 3

  8. Which operator is used for incrementing a variable by 1 in C?

    A) ++ (Increment)

    B) -- (Decrement)

    C) + (Plus)

    D) - (Minus)

    Answer: A) ++ (Increment)

  9. Which operator is used for decrementing a variable by 1 in C?

    A) ++ (Increment)

    B) -- (Decrement)

    C) + (Plus)

    D) - (Minus)

    Answer: B) -- (Decrement)

  10. What is the result of the expression `x = 5; y = x++;` where x initially holds the value 5?

    A) x is 6, y is 5

    B) x is 5, y is 6

    C) x is 5, y is 5

    D) x is 6, y is 6

    Answer: A) x is 6, y is 5

  11. What is the purpose of assignment operators in C?

    A) To perform mathematical calculations

    B) To compare two values

    C) To assign a value to a variable

    D) To print output to the console

    Answer: C) To assign a value to a variable

  12. Which assignment operator is used to assign a value to a variable in C?

    A) = (Equal)

    B) == (Double Equal)

    C) := (Colon Equal)

    D) -> (Arrow)

    Answer: A) = (Equal)

  13. What is the value of the variable `x` after the following assignment: `x = 10;`?

    A) 0

    B) 1

    C) 10

    D) 100

    Answer: C) 10

  14. Which of the following assignment operators is used for addition and assignment?

    A) = (Equal)

    B) += (Plus Equal)

    C) -= (Minus Equal)

    D) *= (Multiply Equal)

    Answer: B) += (Plus Equal)

  15. What will be the value of the variable `y` after the following assignment: `y += 5;` if `y` initially holds the value 7?

    A) 2

    B) 7

    C) 12

    D) 5

    Answer: C) 12

  16. Which assignment operator is used for subtraction and assignment?

    A) = (Equal)

    B) += (Plus Equal)

    C) -= (Minus Equal)

    D) *= (Multiply Equal)

    Answer: C) -= (Minus Equal)

  17. What will be the value of the variable `z` after the following assignment: `z -= 3;` if `z` initially holds the value 9?

    A) 6

    B) 3

    C) 9

    D) -3

    Answer: A) 6

  18. Which assignment operator is used for multiplication and assignment?

    A) = (Equal)

    B) += (Plus Equal)

    C) -= (Minus Equal)

    D) *= (Multiply Equal)

    Answer: D) *= (Multiply Equal)

  19. What will be the value of the variable `w` after the following assignment: `w *= 4;` if `w` initially holds the value 3?

    A) 7

    B) 12

    C) 3

    D) 0

    Answer: B) 12

  20. Which assignment operator is used for division and assignment?

    A) = (Equal)

    B) += (Plus Equal)

    C) /= (Divide Equal)

    D) *= (Multiply Equal)

    Answer: C) /= (Divide Equal)

  21. What is the purpose of relational operators in C?

    A) To perform mathematical calculations

    B) To assign values to variables

    C) To compare values and return a Boolean result

    D) To control the flow of program execution

    Answer: C) To compare values and return a Boolean result

  22. Which relational operator is used to check if two values are equal in C?

    A) == (Equal to)

    B) != (Not equal to)

    C) < (Less than)

    D) > (Greater than)

    Answer: A) == (Equal to)

  23. What will be the result of the expression `5 == 5` using the equal to operator?

    A) True

    B) False

    C) 10

    D) Error

    Answer: A) True

  24. Which relational operator is used to check if two values are not equal in C?

    A) == (Equal to)

    B) != (Not equal to)

    C) < (Less than)

    D) > (Greater than)

    Answer: B) != (Not equal to)

  25. What will be the result of the expression `8 != 5` using the not equal to operator?

    A) True

    B) False

    C) 3

    D) Error

    Answer: A) True

  26. Which relational operator is used to check if a value is less than another value in C?

    A) == (Equal to)

    B) != (Not equal to)

    C) < (Less than)

    D) > (Greater than)

    Answer: C) < (Less than)

  27. What will be the result of the expression `10 < 15` using the less than operator?

    A) True

    B) False

    C) 25

    D) Error

    Answer: A) True

  28. Which relational operator is used to check if a value is greater than another value in C?

    A) == (Equal to)

    B) != (Not equal to)

    C) < (Less than)

    D) > (Greater than)

    Answer: D) > (Greater than)

  29. What will be the result of the expression `20 > 10` using the greater than operator?

    A) True

    B) False

    C) 10

    D) Error

    Answer: A) True

  30. Which relational operator is used to check if a value is less than or equal to another value in C?

    A) <= (Less than or equal to)

    B) >= (Greater than or equal to)

    C) == (Equal to)

    D) != (Not equal to)

    Answer: A) <= (Less than or equal to)

  31. What is the purpose of logical operators in C?

    A) To perform mathematical calculations

    B) To assign values to variables

    C) To combine and manipulate Boolean values

    D) To control the flow of program execution

    Answer: C) To combine and manipulate Boolean values

  32. Which logical operator in C represents logical AND?

    A) && (Double Ampersand)

    B) || (Double Pipe)

    C) ! (Exclamation Mark)

    D) & (Ampersand)

    Answer: A) && (Double Ampersand)

  33. What is the result of the logical AND operation `true && false` in C?

    A) true

    B) false

    C) 1

    D) 0

    Answer: B) false

  34. Which logical operator in C represents logical OR?

    A) && (Double Ampersand)

    B) || (Double Pipe)

    C) ! (Exclamation Mark)

    D) | (Pipe)

    Answer: B) || (Double Pipe)

  35. What is the result of the logical OR operation `true || false` in C?

    A) true

    B) false

    C) 1

    D) 0

    Answer: A) true

  36. Which logical operator in C represents logical NOT?

    A) && (Double Ampersand)

    B) || (Double Pipe)

    C) ! (Exclamation Mark)

    D) ~ (Tilde)

    Answer: C) ! (Exclamation Mark)

  37. What is the result of the logical NOT operation `!true` in C?

    A) true

    B) false

    C) 1

    D) 0

    Answer: B) false

  38. What is the result of the expression `true && (false || true)` in C?

    A) true

    B) false

    C) 1

    D) 0

    Answer: A) true

  39. What is the result of the expression `(true && false) || (false && true)` in C?

    A) true

    B) false

    C) 1

    D) 0

    Answer: B) false

  40. Which logical operator in C has the highest precedence?

    A) &&

    B) ||

    C) !

    D) &

    Answer: C) ! (Exclamation Mark)

  41. What is the purpose of the increment operator (++) in C?

    A) To subtract 1 from a variable

    B) To add 1 to a variable

    C) To multiply a variable by 2

    D) To divide a variable by 2

    Answer: B) To add 1 to a variable

  42. Which operator is used to increment a variable by 1 in C?

    A) -- (Double Minus)

    B) + (Plus)

    C) * (Multiplication)

    D) ++ (Double Plus)

    Answer: D) ++ (Double Plus)

  43. What is the result of `x = 5; y = x++;` in C, where `x` starts with a value of 5?

    A) `x` becomes 6, `y` becomes 6

    B) `x` remains 5, `y` becomes 5

    C) `x` becomes 6, `y` remains 5

    D) `x` remains 5, `y` remains 6

    Answer: C) `x` becomes 6, `y` remains 5

  44. Which operator is used to decrement a variable by 1 in C?

    A) -- (Double Minus)

    B) + (Plus)

    C) * (Multiplication)

    D) ++ (Double Plus)

    Answer: A) -- (Double Minus)

  45. What is the result of `x = 8; y = --x;` in C, where `x` starts with a value of 8?

    A) `x` becomes 7, `y` becomes 7

    B) `x` remains 8, `y` becomes 7

    C) `x` becomes 7, `y` becomes 8

    D) `x` remains 8, `y` becomes 6

    Answer: A) `x` becomes 7, `y` becomes 7

  46. What is the difference between the postfix increment `x++` and the prefix increment `++x` in C?

    A) There is no difference; they both increase `x` by 1.

    B) Postfix increment increases `x` first, while prefix increment increases `x` after the current value is used.

    C) Postfix increment increases `x` after the current value is used, while prefix increment increases `x` first.

    D) Postfix increment doubles the value of `x`, while prefix increment adds 1.

    Answer: B) Postfix increment increases `x` first, while prefix increment increases `x` after the current value is used.

  47. What is the purpose of the decrement operator (--) in C?

    A) To add 1 to a variable

    B) To subtract 1 from a variable

    C) To multiply a variable by 2

    D) To divide a variable by 2

    Answer: B) To subtract 1 from a variable

  48. What is the result of `x = 10; y = x--;` in C, where `x` starts with a value of 10?

    A) `x` becomes 9, `y` becomes 10

    B) `x` remains 10, `y` becomes 9

    C) `x` becomes 9, `y` becomes 9

    D) `x` remains 10, `y` becomes 10

    Answer: A) `x` becomes 9, `y` becomes 10

  49. Which operator is used to increment a variable by a specific value in C?

    A) ++

    B) --

    C) +=

    D) *=

    Answer: C) += (Increment by a specific value)

  50. Which operator is used to decrement a variable by a specific value in C?

    A) ++

    B) --

    C) +=

    D) *=

    Answer: B) --= (Decrement by a specific value)