answersLogoWhite

0


Best Answer

It's a matter of if the variable (in your case, a) is incremented before or after it is referenced. Or so says Hewlett-Packard in their HP-UX C compiler manualNow, as for how the difference matters in a practical manner, see related link below for the explanation- it can do a better explanation than I can.

To quote Wikipedia (legal notice: the following text is licensed under the GNU Free Documentation License):

The precedence table determines the order of binding in chained expressions, when it is not expressly specified by parentheses.

  • For example, ++x*3 is ambiguous without some precedence rule(s). The precedence table tells us that: x is 'bound' more tightly to ++ than to *, so that whatever ++ does (now or later-see below), it does it ONLY to x (and not to x*3); it is equivalent to (++x, x*3).
  • Similarly, with 3*x++, where though the post-fix ++ is designed to act AFTER the entire expression is evaluated, the precedence table makes it clear that ONLY x gets incremented (and NOT3*x); it is functionally equivalent to something like (tmp=3*x, x++, tmp) with tmp being a temporary value.

Precedence and bindings

  • Abstracting the issue of precedence or binding, consider the diagram above. The compiler's job is to resolve the diagram into an expression, one in which several unary operators ( call them 3+( . ), 2*( . ), ( . )++ and ( . )[ i ] ) are competing to bind to y. The order of precedence table resolves the final sub-expression they each act upon: ( . )[ i ] acts only on y, ( . )++ acts only on y[i], 2*( . ) acts only on y[i]++ and 3+( . ) acts 'only' on 2*((y[i])++). It's important to note that WHAT sub-expression gets acted on by each operator is clear from the precedence table but WHEN each operator acts is not resolved by the precedence table; in this example, the ( . )++ operator acts only on y[i] by the precedence rules but binding levels alone do not indicate the timing of the Suffix ++ (the ( . )++ operator acts only after y[i] is evaluated in the expression).

Many of the operators containing multi-character sequences are given "names" built from the operator name of each character. For example, += and -= are often called plus equal(s) and minus equal(s), instead of the more verbose "assignment by addition" and "assignment by subtraction".

The binding of operators in C and C++ is specified (in the corresponding Standards) by a factored language grammar, rather than a precedence table. This creates some subtle conflicts. For example, in C, the syntax for a conditional expression is: logical-OR-expression ? expression : conditional-expression

while in C++ it is: logical-or-expression ? expression : assignment-expression

Hence, the expression: e = a < d ? a++ : a = d

is parsed differently in the two languages. In C, this expression is a syntax error, but many compilers parse it as: e = ((a < d ? a++ : a) = d)

which is a semantic error, since the result of the conditional-expression (which might be a++) is not an lvalue. In C++, it is parsed as: e = (a < d ? a++ : (a = d))

which is a valid expression.

The precedence of the bitwise logical operators has been criticized.[1] Conceptually, & and | are arithmetic operators like + and *.

The expression ​a & b 7​. This requires parentheses to be used more often than they otherwise would.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How does plus plus a differ from a plus plus in c language?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How does oracle differ from c plus plus?

The first in a company developping a well-known database system, the second is a programming language.


How do stuctures in C and C plus plus differ?

Structures in C and C++ differ in that C structures do not have an automatic typdef associated with them.


In computer language C plus plus is related to?

C++ is related to C, the language from which it is derived.


What are the interpreter in c plus plus?

C++ is a compiled language, not an interpreted language.


Turbo C plus plus keywords?

Turbo C++ keywords are the same as C++ keywords. The language remains the same, only the implementations differ. The Turbo C++ implementations were standards-compliant at the time of their release, but the product is no longer supported.


Is c plus plus a complied or interpreted language?

C++ is generally a compiled language.


Is C plus plus a high level language?

Yes, C++ is a high-level language.


Who is the owner of c plus plus language?

Bjarne Stroustrup is the author of C++. However, no one "owns" this language.


What is the significance of c plus plus?

C++ is an object oriented programming language


What do the two plus stand for in C plus plus?

The ++ in C++ refers to the postfix increment operator (operator++()). It's literal meaning is "the successor to C", in reference to the C language upon which the C++ language is based.


Is c plus plus a structured language?

Yes


Who created 'C Plus Plus ' language and when?

C ++ is a computer progamming language just like Java, Python and Perl or even its predecessor 'C'.