Possible Duplicates:
What is more efficient i++ or ++i?
How do we explain the result of the expression (++x)+(++x)+(++x)?
Difference between i++ and ++i in a loop?
I am trying these two programs:
void fun(){
int k = 0;
int i= 10;
k = (i++)+(++i);
cout << k << endl;
}
Output = 22 as i++ will give 10 and ++i will evaluate into 12.
But
void fun(){
int k = 0;
int i = 10;
k = (++i)+(++i);
cout << k << endl;
}
Output = 24
It should be 23 I guess, or is there something that I am not able to see?
Duplicate may be used as a noun, verb or adjective. Related words are duplicates, duplicated, duplicating, duplication. The word duplicate is derived from the Latin word duplicare, which means to double. Replicate means to reproduce something, to construct a copy of something, to make a facsimile.
: either of two things exactly alike and usually produced at the same time or by the same process. : an additional copy of something (such as a book or stamp) already in a collection. : one that resembles or corresponds to another : counterpart. 3. : two identical copies.
By default, the File menu shows Duplicate below the Save item. Choosing File > Duplicate creates a copy of the current state of the file, including unsaved changes. The copy is a separate document that has as its name the original file's title plus the word “Copy,” and the title is highlighted.
Duplicate Document means a written counterpart of the original produced by the same impression as the original or from the same matrix or by digitized electronic transmission, readable by sight, which accurately reproduces the original.(B) Filing by Electronic Facsimile Transmission.
Note: you are invoking undefined behavior (modifying a variable twice between sequence points)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With