What you've shown suggests you had an error in the first test. end_time was used uninitialized. You need to run the program that shows the problem to confirm it happens and then copy and paste exactly that code completely in one piece so we can see exactly what you ran and can try it ourselves.
Seems that compiler think in different way as human (of course) ~_~
I expect the cout code will invoke MyTimerEnd() first and then MyElapseTime(). but compiler not think in that way.
When I change to:
To avoid that the execution of cout << "Program finished at " is being included in your timings I think you should stop the timer on its own line, before using cout.
Also note that clock() tries to estimate the time that your CPU spends executing your program so the 3 seconds that your program spends sleeping will probably not be included in the timings.