This program is stuck in an infinite loop when i++ is used but gives right output when ++i is used. Why does this happen if we use post-increment rather than pre-increment.
#include <iostream>
int main (){
    int i = 0;
    while (i < 5)
    {
        std::cout << i;
        i = i++;
    }
}
 
     
    