Hi,
I'm currently enrolled in programming fundamentals for computer science class at the local community college.
Testing out what the results would be if I use a++ and ++a where a is a variable of integer data type initialized to 0.
When I run the program, I get different results.Code:#include <iostream> using namespace std; int main() { int a = 0; cout << "a++ = " << a++ <<endl; cout << "++a = " << ++a <<endl; cin.get(); return 0; }
a++ prints out 0 and ++a prints out 1.
If both a++ and ++a increment the value of variable a by 1, why are the results different? Can someone point me in the right direction?
Thank you