lundi 20 avril 2020

Post increment C++ Output [duplicate]

#include<iostream>
using namespace std;
int main()
{
    int a=5, b;
    cout<<a++<<endl<<a++<<endl<<++a<<endl<<++a<<endl<<++a<<endl<<a++<<endl<<a++<<endl<<a++<<endl<<a++<<endl<<++a;
    return 0;
}

OUTPUT: 14 13 15 15 15 9 8 7 6 15

Can someone explain how the compiler got this output? I understood the pre-increment will be 15. But can someone explain how we're getting these post-increment values?

Aucun commentaire:

Enregistrer un commentaire