+ 6

Difference between ++x, x++

11th Oct 2016, 6:00 PM
Ankush Bairwa
Ankush  Bairwa - avatar
8 Respostas
+ 18
The increment operator has two forms, prefix (++x) and postfix (x++). Prefix increments the value, and then proceeds with the expression. Postfix evaluates the expression and then performs the incrementing. as an example, int pre, post, x, y; pre = 10; post = 10; x = ++pre; //x is 11 y = post++; //y is 10
11th Oct 2016, 6:15 PM
Celal Aybar
Celal Aybar - avatar
+ 3
++x is pre-increment, it will work before the execution of the statement. for example: int a=1; cout<<++a; it will give output 2. while x++ is post-increment it will work after the execution of the statement. for example: int a=1; cout<<a++; it will give output 1. still hv doubt then feel free to tell.
11th Oct 2016, 6:18 PM
Prabhakar Jha
Prabhakar Jha - avatar
+ 1
y value is 11
24th Nov 2016, 6:26 AM
pravin soundar
pravin soundar - avatar
+ 1
Execute the below program, int x=10; //Pre increment z=++x; // Value of z will be 11 //Post Incrememt z=x++;// Value of z will be 11 itself
25th Nov 2016, 3:56 PM
Nandan B N
Nandan B N - avatar
+ 1
++x is prefix incrementit increases the value first then assigns it. x++ is postfix increment,it assigns the value first then increases the value
5th Mar 2017, 9:00 AM
Abhimanyu Singh
Abhimanyu Singh - avatar
0
post increment value can not be increment
10th Dec 2016, 5:34 PM
nagaraju
nagaraju - avatar
0
because of first increment and after value is appear...
10th Dec 2016, 5:35 PM
nagaraju
nagaraju - avatar
0
++x ll first increment n assign the value..while x++ ll assign n increment the value of x.x=10 & x++ value is 10 & ++x value is 11
14th Dec 2016, 5:52 PM
pravin soundar
pravin soundar - avatar