Thanks
Suk nta
Posts
-
Increment and Decrement Operators -
Increment and Decrement OperatorsI know increment and decrement operator depend on compiler. actually i had tried it in dev c++.
-
Increment and Decrement Operatorsno no..in any compiler prefix operator execute first than postfix. postfix will execute after value returned or assigned to some variable..
-
Increment and Decrement Operatorshey i want to rectify Message send by Richard MacCutchan
int i = 10;
int result;
result = i++; // result equals 10, i equals 11
result = ++i; // result equals 12, i equals 12
result = i--; // result equals 12, i equals 11
result = --i; // result equals 10, i equals 10// note do not use expressions such as
result = ++i + i++; // results undefinedAs written the last line gives output undefine i think its wrong .it will give correct output as 23.
If u had checked then u already got the result.
here i will explan u how it's work..1:from left to right ++i changes i values 10 to 11.
2:then it will add 11 + 11 (as i++ is post increment operator it will execute after expression execution) and gives result as 22
3: then i values becomes 22 and i++ will going to execute and i value changes to 22+1=23 -
Increment and Decrement Operatorshey i want to rectify Message send by Richard MacCutchan
int i = 10;
int result;
result = i++; // result equals 10, i equals 11
result = ++i; // result equals 12, i equals 12
result = i--; // result equals 12, i equals 11
result = --i; // result equals 10, i equals 10// note do not use expressions such as
result = ++i + i++; // results undefinedAs written the last line gives output undefine i think its wrong .it will give correct output as 23. If u had checked then u already got the result. here i will explan u how it's work.. 1:from left to right ++i changes i values 10 to 11. 2:then it will add 11 + 11 (as i++ is post increment operator it will execute after expression execution) and gives result as 22 3: then i values becomes 22 and i++ will going to execute and i value changes to 22+1=23