0% found this document useful (0 votes)
2 views3 pages

Operators

The document contains a series of questions and answers related to C programming operators, including logical AND, bitwise OR, operator precedence, division results, modulo operation, and the ternary operator. It also discusses the output of a specific code snippet involving increment operators. The answers provided clarify the correct operator usage and expected results for each question.

Uploaded by

Vijaya kumari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Operators

The document contains a series of questions and answers related to C programming operators, including logical AND, bitwise OR, operator precedence, division results, modulo operation, and the ternary operator. It also discusses the output of a specific code snippet involving increment operators. The answers provided clarify the correct operator usage and expected results for each question.

Uploaded by

Vijaya kumari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Operators

1.​ Which operator is used for logical AND in C?​

○​ a) &
○​ b) &&
○​ c) |
○​ d) ||
○​ Answer: b) &&
2.​ Which operator is used for bitwise OR in C?​

○​ a) &
○​ b) &&
○​ c) |
○​ d) ||
○​ Answer: c) |
3.​ Which operator has the highest precedence?​

○​ a) +
○​ b) *
○​ c) ()
○​ d) =
○​ Answer: c) ()
4.​ What is the result of 5 / 2 in C?​

○​ a) 2.5
○​ b) 2
○​ c) 3
○​ d) 2.0
○​ Answer: b) 2
5.​ Which operator is used for the modulo (remainder) operation?​

○​ a) /
○​ b) %
○​ c) *
○​ d) \
○​ Answer: b) %

6.What is the value of x after the following code?​


int x = 5;
x += 3;

○​ a) 5
○​ b) 3
○​ c) 8
○​ d) 2
○​ Answer: c) 8
6.​ Which operator is used for the "not equal to" comparison?​

○​ a) =
○​ b) ==
○​ c) !=
○​ d) <>
○​ Answer: c) !=
7.​ What is the result of 10 >> 2?​

○​ a) 2
○​ b) 20
○​ c) 5
○​ d) 2.5
○​ Answer: a) 2

9.What is the ternary operator equivalent of the following code?​



C​
if (x > 5) {
y = 10;
} else {
y = 20;
}
○​ a) y = (x > 5) ? 10 : 20;
○​ b) y = (x < 5) ? 10 : 20;
○​ c) (x > 5) ? y = 10 : y = 20;
○​ d) (x < 5) ? y = 10 : y = 20;
○​ Answer: a) y = (x > 5) ? 10 : 20;

10.What is the output of the following code?​


int a = 5;
printf("%d", ++a * a++);

○​ a) 25
○​ b) 30
○​ c) 36
○​ d) Undefined Behavior
○​ Answer: d) Undefined Behavior (order of operations on
incrementing variables in a single expression can vary by
compiler)

You might also like