Home > Back-end >  Why is x * y (x) * (y), whether p=x * y is do the multiplication first
Why is x * y (x) * (y), whether p=x * y is do the multiplication first

Time:09-24

Uh uh uh uh uh uh uh uh uh uh uh

CodePudding user response:

Because + + the operator precedence than *, who preferred if operations, to baidu C operator precedence table

CodePudding user response:

Your question has nothing to do with the sequence
Y++ result is y
So the value of x * y++ and x * y have the same value

In addition
Priority and the order of operations

CodePudding user response:

I didn't understand your question, will you please take code description of your problem

CodePudding user response:

Y++ the + + the y will only take effect after being used, so the title you can understand it
P=x * y
y++

CodePudding user response:

refer to the second floor lin5161678 response:
your problem has nothing to do with the sequence
Y++ result is y
So the value of x * y++ and x * y have the same value

In addition
Priority has nothing to do with the sequence
is x=1, y=1,
X * y++ result is 1

CodePudding user response:

just learning c reference 5 floor super super super rookie response:
Quote: refer to the second floor lin5161678 response:
your problem has nothing to do with the sequence
Y++ result is y
So the value of x * y++ and x * y have the same value

In addition
Priority has nothing to do with the sequence
is x=1, y=1,
X * y++ result is 1

Operation after the y value will add one, before the + + operation is operation is executed, the + + operation is executed after when it performs + + operations

CodePudding user response:

(y++) and x (x) * * y++ run results are the same as
You can't change this rule, how much parenthesis
P=x * y++, is to use the x, y, calculated the value of p, now and then to add 1 y, is equal to p=(x * y, y++);

CodePudding user response:

Ah, have forgotten the very 6 capitalization,
The basic has been salted fish are:
.
i++;
.

CodePudding user response:

P=x * y++;
The first two adjacent operator

A=B * C.

* priority than=, so the return value of the priority calculation B * C expression, expression which compute y++] [x * the return value of x,
Return (A=X] expression return values;// this attention, such as A=88 here is not the expression of the return value, it's just happened to run into the same here
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
X * y++;
The first two adjacent operator

M * N++

+ + priority than *, so priority calculation N++ expression of the return value, namely the calculation [N++] the return value of X,
Return [M] * X expressions return values;
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
N++;
An operator

Step1: N=N + 1;
Step2: return since before increasing N
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

This formula is summed up down
P=x * y++;
Operation: according to priority set x=3, y=2, p=null
1. Y++ expression [y on the y=2, return to y, return 1]
The return value of (1) (2) x * [return 3 * 2=6]
3. P=return value (2) [p assigned a value of the return value of 2, returns the value of p (this value is not used in the formula)

CodePudding user response:

references 9 f thousand dream life response:
p=x * y++;
The first two adjacent operator

A=B * C.

* priority than=, so the return value of the priority calculation B * C expression, expression which compute y++] [x * the return value of x,
Return (A=X] expression return values;// this attention, such as A=88 here is not the expression of the return value, it's just happened to run into the same here
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
X * y++;
The first two adjacent operator

M * N++

+ + priority than *, so priority calculation N++ expression of the return value, namely the calculation [N++] the return value of X,
Return [M] * X expressions return values;
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
N++;
An operator

Step1: N=N + 1;
Step2: return since before increasing N
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

This formula is summed up down
P=x * y++;
Operation: according to priority set x=3, y=2, p=null
1. Y++ expression [y on the y=2, return to y, return 1]
The return value of (1) (2) x * [return 3 * 2=6]
3. P=return value (2) [p assigned a value of the return value of 2, returns the value of p (this value is not used in the formula)


A recursive evaluated from left to right

CodePudding user response:

The + + operator priority is higher

CodePudding user response:

A=b;
//it is not only an assignment operation, also is an expression, as long as the expression has a return value, two operations
c++;
//this is both a since the operation, also is an expression, as long as the expression has a return value, two operations
  • Related