+ 4

In increment and decrement operator one question is there right what is answer for that question? It's post decrement operation therefore answer should be 18 right? but it's showing as wrong when I enter 18

26th Aug 2016, 1:53 PM
Nagesh R Prabhu
Nagesh R Prabhu - avatar
5 Answers
+ 3
this is because in that question u r printing that value after decrement... in simple words we can say that once you have entered value 18 and then u decrement it and then print it.. so the value that print is the value after decrement.
28th Aug 2016, 10:05 AM
Haripriya
Haripriya - avatar
0
After increment and decrement unit
26th Aug 2016, 2:38 PM
Nagesh R Prabhu
Nagesh R Prabhu - avatar
0
the answer to that question is 17; that is post decrement operator. search for post decrement operator for better understanding.
5th Sep 2016, 3:18 AM
Ayaz Muttaqui
Ayaz Muttaqui - avatar
0
I don't understand
4th Jan 2017, 1:39 PM
Kaung Khant
Kaung Khant - avatar
- 1
maybe 2 samples will help you. $a=1; $b=++$a; echo $a,$b; this will output 2 and 2. give a the value 1 and before (preincrement) giving a's value to b, it ads 1 to it, making a,2 and b, 2. $a=1; $b=$a++; echo $a,$b; this will output 2 and 1. give a the value 1 and after (postincrement) giving a's value to b it ads 1 to it, making a, 2 and b, 1. either way, the 'echo' comes AFTER ALL OTHER operation, including decrementing the variable; and that's why the answer to the quiz is 17.
29th Dec 2016, 9:54 AM
m g