 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Is there a performance difference between i++ and ++i in C++?
There is a big distinction between the suffix and prefix versions of ++.
- In the prefix version (i.e., ++i), the value of i is incremented, and the value of the expression is the new value of i. So basically it first increments then assigns a value to the expression. 
- In the postfix version (i.e., i++), the value of i is incremented, but the value of the expression is the original value of i. So basically it first assigns a value to expression and then increments the variable. 
Let's look at some code to get a better understanding.
Example Code
#include<iostream> using namespace std; int main() {    int x = 3, y, z;    y = x++;    z = ++x;    cout << x << ", " << y << ", " << z;    return 0; }  Output
5, 3, 5
Let's look at it in detail
- Initialize x to 3 
- Assign y the value we get by evaluating the expression x++, ie, the value of x before increment then increment x. 
- Increment x then assign z the value we get by evaluating the expression ++x, ie, value of x after the increment. 
- Print these values 
