+ 1
what does x++*y-- mean?
14 Respuestas
+ 34
Try this example to understand better ;)
int main() {
int x=10;
int y=2;
cout<< x++*y--;
}
+ 11
x++ is postfix increment and y is postfix decrement, postfix means the values of x and y will be used first in the expression after that increment/decrement operation will be applied.
eg :
int x=5,y=4;
int z=x++*y--;
//value of z will be 20 (5*4)
//value of x will be 6 and value of y will be 3
+ 6
calculate x * y and increase x, decrease y.
+ 2
++ and -- are unary operators which help in increasing or decreasing the value by one. If x is the operand in an statement and if the ++or-- are placed before the operand then the value of x will first get changed and then it will be kept in the statement and if the operators are after the operand then the value will first be kept in statement and then it will be changed.
eg- If x=5 and y=4 and c=++x-y
then c=6-4=2 while if c=x++-y then c=5-4=1but after this the value of x will be 6
+ 1
first will be using in expression, after that post incrementation and post decrementation :
example for explanation post and pre (increment and decrement value)
int a = 5;
int b = 5;
int c = 5;
int d = 5;
cout<<" a++ = "<< a++
<<"\nb-- = "<< b--
<<"\n++c = "<< ++c
<<"\n--d = "<< --d ;
/* displayed expression
result: a++ = 5
b-- = 5
++c = 6
--d = 4
different case is with "pre" incrementation/decrementation . First we have to calculate experience and after that use it*/
cout<<"a = "<< a
<<"\nb = "<< b
<<"\nc = "<< c
<<"\nd = "<< d;
/*displayed values after using expressions
result: a = 6
b = 4
c = 6
d = 4
I used "\n" == it mean "new line" */
so:
a++*b-- , a--*b++... /* or other combination will be in result = 25 */
// sorry for my english :)
0
it will first use the values of x and y as like it gets from the user and for the next looping the value of x will increase by 1 and y value will decrease by 1 this is the example for post increment and pre decrement concept
0
Please type in a code to print to the screen the value of x divided by y.
int x = 81;
int y = 3;
______<< x ________ y << endl ;
0
x++ is a shortened way of saying x + 1, and y-- is a shortened way of saying y - 1. So x++*y-- would mean (x + 1) * (y - 1).
For example, if x was 5 and y was 3, x++*y-- would be 12, because 5 + 1 is 6 and 3 - 1 is 2. 6 * 2 is 12.
- 2
Please type in a code to print to the screen the value of x divided by y.
int x = 81;
int y = 3;
<< x
y << endl;
- 2
Please type in a code to print to the screen the value of x divided by y.
int x = 81;
int y = 3;
______<< x ________ y << endl ;
- 3
X++ = x+1
y-- = y-1
Lets x=4 and y=3
If there Is no loop.
Then,
Answer will be (4++)*(3--)=12
As post increment used.
Afterward i'll give you - > 10, 6, 0, - 8 and so on
- 5
Please type in a code to print to the screen the value of x divided by y.
int x = 81;
int y = 3;
<< x
y << endl;
- 6
x+1=11 as the new value of x post fixing....
but y- is nothing y remains as 2....
11*2=22
is that the correct answer????? Emma
- 9
Emma what's your Facebook?