FAHEEM_KAHN's blog

By FAHEEM_KAHN, history, 79 minutes ago, In English
#include <iostream>
using namespace std;
int main() {
    int a=1;
    int b;
    b = ++a * ++a;
    cout<<"a: "<<a<<", b: "<<b; cout<<endl;

    a=1; b = a++ * a++;
    cout<<"a: "<<a<<", b: "<<b; cout<<endl;

    a=1; b = ++a * a++;
    cout<<"a: "<<a<<", b: "<<b; cout<<endl;

    a=1; b = a++ * ++a;
    cout<<"a: "<<a<<", b: "<<b; cout<<endl;
}

OUTPUT:
// a: 3, b: 9
// a: 3, b: 2
// a: 3, b: 6
// a: 3, b: 3

Can anyone explain why, this is the output?

Full text and comments »

Tags cpp
  • Vote: I like it
  • -5
  • Vote: I do not like it