answersLogoWhite

0


Best Answer

Operator

Description

Associativity

()
[]
.
->
++ -- Parentheses (function call) (see Note 1)
Brackets (array subscript)
Member selection via object name
Member selection via pointer
Postfix increment/decrement (see Note 2)

left-to-right

++ --
+ -
! ~
(type)
*
&
sizeof Prefix increment/decrement
Unary plus/minus
Logical negation/bitwise complement
Cast (change type)
Dereference
Address
Determine size in bytes right-to-left * / % Multiplication/division/modulus left-to-right + - Addition/subtraction left-to-right << >> Bitwise shift left, Bitwise shift right left-to-right < <=
> >= Relational less than/less than or equal to
Relational greater than/greater than or equal to left-to-right == != Relational is equal to/is not equal to left-to-right & Bitwise AND left-to-right ^ Bitwise exclusive OR left-to-right | Bitwise inclusive OR left-to-right && Logical AND left-to-right Logical OR left-to-right ?: Ternary conditional right-to-left =
+= -=
*= /=
%= &=
^= |=
<<= >>= Assignment
Addition/subtraction assignment
Multiplication/division assignment
Modulus/bitwise AND assignment
Bitwise exclusive/inclusive OR assignment
Bitwise shift left/right assignment right-to-left

,

Comma (separate expressions) left-to-right
User Avatar

Wiki User

8y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

Operator precedence describes the order in which C reads expressions. For example, the expressiona=4+b*2 contains two operations, an addition and a multiplication. Does the C compiler evaluate 4+bfirst, then multiply the result by 2, or does it evaluate b*2 first, then add 4 to the result? The operator precedence chart contains the answers. Operators higher in the chart have a higher precedence, meaning that the C compiler evaluates them first. Operators on the same line in the chart have the same precedence, and the "Associativity" column on the right gives their evaluation order.

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

An operator is a pre-defined token that performs an operation. Some operations use the same token, the actual operation being dictated by the context. For instance, the * token can be used to dereference a pointer operand or to multiply two operands. Similarly, the & token can be used to obtain the address of an operand or to perform a bitwise AND upon two operands.

Operator precedence and associativity in C++ is as follows:

Precedence 1 (left-to-right)

:: Scope resolution operator

Precedence 2 (left-to-right)

++, -- Postfix increment/decrement

() function call

[] array subscript

. member-of reference

-> member-of pointer

Precedence 3 (right-to-left)

++, -- Prefix increment/decrement

+, - Unary plus/minus

!, ~ Logical/bitwise NOT

(type) Typecast

* Indirection (dereference)

& Address-of

sizeof Size of type

new, new[] Dynamic allocation

delete, delete[] Dynamic deallocation

Precedence 4 (left-to-right)

.*, ->* Pointer to member

Precedence 5 (left-to-right)

*, /, % Multiplication, division and modulus

Precedence 6 (left-to-right)

+, - Binary addition/subtraction

Precedence 7 (left-to-right)

<<, >> Bitwise shift left/right

Precedence 8 (left-to-right)

<, <=, >, >= Relational operators

Precedence 9 (left-to-right)

==, != Equality/inequality

Precedence 10 (left-to-right)

& Bitwise AND

Precedence 11 (left-to-right)

^ Bitwise XOR

Precedence 12 (left-to-right)

| Bitwise OR

Precedence 13 (left-to-right)

&& Logical AND

Precedence 14 (left-to-right)

Logical OR

Precedence 15 (right-to-left)

?: Ternary conditional

= Assignment

+=, -= Compound assignment/subtraction

*=, /=, %= Compound multiply/divide/modulus

<<=, >>= Compound shift left/right

&=, |=, ^= Compound bitwise AND/OR/XOR

Precedence 16 (right-to-left)

throw Exception

Precedence 17 (left-to-right)

, Comma

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is operator associativity in C?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Which operator has associative from R to L in C programming Language?

Assignment (=) is the first one popped up in my mind. BUT,there are more than 1 operator in C has associativity from right to left:unary + and - (e.g., +1, -1, -x)prefix ++ and -- (e.g., ++x)sizeofnegate ! and ~ (e.g. !x)reference and de-reference & and * (e.g. &x, *x)assignments=, +=, -=, *=, /=, %==, &=, |=, ^=


How many operators in c?

Quite a few. Some of them are: , () [] &amp; * . -&gt; + ++ += - -- -= * / % *= /= %= ! == &lt;= &gt;= &lt; &gt; != &lt;&lt; &gt;&gt; &gt;&gt;= &lt;&lt;= &amp; | ^ ~ &amp;&amp;


Associativity has no role to play unless the precedence of operator isHow much memory is required to store a value of type double?

yes


How do you evaluate an expression in hierarchy of operations?

Expressions are evaluated according to the language grammar. Operator precedence and associativity are derived from the grammar in order to aid our understanding, however the order of evaluation is independent of both because the C language standard does not specify operator precedence. The general arithmetic rules of precedence hold for most expressions such that parenthesised operations take precedence over orders followed by multiplication/division operations and finally addition/subtraction operations (as per the PODMAS acronym). Many of the more complex expressions we encounter can generally be evaluated according to the operator precedence table, which includes the associativity, such that operations with higher precedence are bound more tightly (as if with parenthesis) than those with lower precedence.


What is the operator is used to allocate the memory in c plus plus?

calloc operator,malloc operator

Related questions

Which direction are java operators evaluated from?

It depends on the operator. Some have right-to-left associativity, some are left-to-right, some have no associativity.


Which operator has associative from R to L in C programming Language?

Assignment (=) is the first one popped up in my mind. BUT,there are more than 1 operator in C has associativity from right to left:unary + and - (e.g., +1, -1, -x)prefix ++ and -- (e.g., ++x)sizeofnegate ! and ~ (e.g. !x)reference and de-reference & and * (e.g. &x, *x)assignments=, +=, -=, *=, /=, %==, &=, |=, ^=


How many operators in c?

Quite a few. Some of them are: , () [] &amp; * . -&gt; + ++ += - -- -= * / % *= /= %= ! == &lt;= &gt;= &lt; &gt; != &lt;&lt; &gt;&gt; &gt;&gt;= &lt;&lt;= &amp; | ^ ~ &amp;&amp;


Associativity has no role to play unless the precedence of operator isHow much memory is required to store a value of type double?

yes


What do associative mean in a math term?

A binary operator is a mathematical operator that performs some operation (eg addition, multiplication) on two operands to produce a result. Associativity is the property of some binary operators whereby, if there is a sequence of such operations, the order in which the operations are carried out does not matter. However, the order of the operands may affect the result. For example, (a + b) + c = a + (b + c) and so we may write them simply as a + b + c.


What are the basic operator in turbo c?

+ += - -= * *= / /= % %= = == != &lt;= &gt;= &amp; &amp;&amp; | ^ ~ &lt;&lt; &lt;&lt;= &gt;&gt; &gt;&gt;= , [] () are the basic operator in TURBO C


What is the operator that cannot be overloaded in c plus plus and java?

conditional operator , size of operator , membership operator and scope resulation operator can not be overload in c++


Use of scope resolution operator in C programming?

:: operator can not be used in C.


What is the memory management operator in c plus plus?

There is no memory management operator in C++ -- it is an unmanaged language. You use the C++ new operator to allocate memory, and use the C++ delete operator to release previously allocated memory.


Is it possible to do operator overloading in c?

No. Operator and/or function overloading is only a C++ thing.


What is commutative and associative in math?

A binary operator is a mathematical operator that performs some operation (eg addition, multiplication) on two operands to produce a result. Commutativity is the property of some binary operations whereby, the order of the operands does not matter. For example, a + b = b + a Associativity is the property of some binary operators whereby, if there is a sequence of such operations, the order in which the operations are carried out does not matter. However, the order of the operands may affect the result. For example, (a + b) + c = a + (b + c) and so we may write them simply as a + b + c.


What is condional operator?

Conditional Operator- Its the only ternary operator in c/c++.- Its syntax is-(condition)?statement1:statement2;-Shruti Jain