- 2
Increament operators
what does this really mean ? and where we can use it ? any details ? thanks
12 Answers
+ 4
There would be a difference, you are overthinking this it feels like.
num3 = num2 ++ + ++num1
which translates to
num3 = num2 + (num1 +1)
(num2 + 1)
Again,
Pre (before)
Post (After)
+ 1
hope this will help you
http://www.c4learn.com/java/java-increment-decrement-operator/
for demo code
https://www.w3schools.com/js/tryit.asp?filename=tryjs_oper_incr
0
ty
0
but didnt understand the difference between of 2++ & ++2 or something like this
0
Think about it as pre and post.
Pre: Before. Increment the value before using it in the statement.
Post: Increment the value after using it in the statement.
So cout << ++2 would output 3 because we increment 2 BEFORE using it in the cout statement.
cout << 2++ would output 2 then increment 2 by 1 to 3 AFTER using the 2 in the cout statement.
0
x=5
y=x++
cout<<y; is 6?
if yes then what about this ?
x=5
y=++x
cout<<y; ??? Josh Schweigert
0
no opposite.
0
Josh Schweigert can u pls expain this issue in any other way ?
0
You have the exact thing just backwards. I don't know how to be any more clear.
0
int num1;
int num2;
int num3;
num1=100;
num2=++num1;
num3=num2++ + ++num1
in here in num3 the value of num2 is 101+1=102 + 1+100 which is equals to 203...
my question is that num2++ or ++num2 is the same ? because both adds 1 to the value. if yes then what is the difference...
Josh Schweigert
0
When the ++ sign is before the value then it is called pre increment which means the value is incremented before termination and if the ++ sign is after the value then the value is incremented at the next step of termination.
Hope it helps you
0
Quisiera hacer una tabla de multiplicar del 1 al 10, y tengo hecho
<?php
//$b es el multiplicando
$b = array(1,2,3,4,,5,6,7,8,9);
$producto = 0;
//$u es el multiplicador
$u = 1;
for ($u = 1; $u <= 10; $u++) {
$producto *= $b[$u];
}
echo "El valor del producto es = $producto . <br />;
?>
El problema que tengo es que no me funciona la lĂnea $producto *= $b[$u]. CĂłmo se harĂa?
Gracias