arrow
arrow
arrow
Consider the operators used in C Programming given below: A. && B. += C. >> D. >= E. ?: Choose among the following
Question

Consider the operators used in C Programming given below:
A. &&
B. +=
C. >>
D. >=
E. ?:
Choose among the following the correct order of precedence of the operators given above (higher to lower):

A.

C, D, E, B, A

B.

C, A, D, E, B

C.

C, D, A, E, B

D.

D, C, A, B, E

Correct option is C


The question asks about the precedence of operators in C programming. The given operators are:
A. && (Logical AND)
B. += (Assignment with addition)
C. >> (Right shift)
D. >= (Greater than or equal to)
E. ?: (Ternary conditional operator)
In C, operators have a specific precedence that determines the order in which operations are executed. Let's analyze the precedence of each operator in the context of C programming.
Precedence of Operators in C:
C. >> (Right Shift): The right shift (>>) operator has higher precedence compared to the other operators in this list except for the ternary operator. The shift operators have precedence over relational, logical, and assignment operators.
D. >= (Greater than or Equal to): The relational operators like >= have precedence after the shift operators but before logical and assignment operators. These are used for comparisons.
A. && (Logical AND): The logical AND (&&) operator comes after relational operators and is evaluated after comparison operators like >=. It has a lower precedence compared to relational and shift operators.
E. ?: (Ternary Conditional Operator): The ternary conditional operator (?:) has higher precedence than logical operators but lower precedence than the shift and relational operators. It is used for conditional expressions.
B. += (Addition Assignment): The addition assignment operator (+=) has low precedence compared to the relational, logical, shift and ternary operators. Assignment operators generally have the lowest precedence, which is why they are evaluated last.
Correct Order of Precedence (Higher to Lower):
1. C. >> (Right shift)
2. D. >= (Greater than or equal to)
3. A. && (Logical AND)
4. E. ?: (Ternary conditional operator)
5. B. += (Addition assignment)
Correct Answer: Option c: C, D, A, E, B
Information Booster:
1. Right Shift (>>): Shift operators have high precedence in C and are executed before relational and logical operators.
2. Relational Operators (>=): These comparison operators come after shift operators but before logical operators.
3. Logical AND (&&): Logical operators like && have lower precedence than comparison operators and shift operators.
4. Ternary Conditional (?:): The ternary operator has a higher precedence than logical operators but lower than relational and shift operators.
5. Assignment (+=): Assignment operators, including +=, have the lowest precedence, which is why they are evaluated last.
Additional Knowledge:
· Operator Precedence in C: The precedence of operators defines the order in which operations are performed in an expression. When operators have the same precedence, associativity (left-to-right or right-to-left) determines the order in which they are evaluated.
· Parentheses can be used to override the default precedence order and explicitly specify the order of operations.

Free Tests

Free
Must Attempt

Basics of Education: Pedagogy, Andragogy, and Hutagogy

languageIcon English
  • pdpQsnIcon10 Questions
  • pdpsheetsIcon20 Marks
  • timerIcon12 Mins
languageIcon English
Free
Must Attempt

UGC NET Paper 1 Mock Test 1

languageIcon English
  • pdpQsnIcon50 Questions
  • pdpsheetsIcon100 Marks
  • timerIcon60 Mins
languageIcon English
Free
Must Attempt

Basics of Education: Pedagogy, Andragogy, and Hutagogy

languageIcon English
  • pdpQsnIcon10 Questions
  • pdpsheetsIcon20 Marks
  • timerIcon12 Mins
languageIcon English
test-prime-package

Access ‘UGC NET Computer Science’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
354k+ students have already unlocked exclusive benefits with Test Prime!
Our Plans
Monthsup-arrow