I\'m willing to write a code that makes my CPU execute some operations and see how much time does he take to solve them. I wanted to make a loop going from i=0 to i<5000
It is often very difficult to get the compiler to keep the code you are interested in profiling.
I highly recommend profiling the actual code that does something useful as there are so many pitfalls in predicting the timing of actual code based on a number of separate measurements.
If you wish to continue, one option is to declare a variable as volatile and assign your answer to it.
volatile int a = i * 434243;
Another is to create a function and return the value. You may need to disable in-lining.
You are very unlikely to answer a question like "how long does a multiply take?". You are always answering questions like, "how long does it take to do a multiply and give me the answer?".
You typically need to "keep temps" and inspect the assembler to make sure it is doing what you expect. If you are calling a function then you may want to compare calling a function that does nothing to try and eliminate calling overhead from your timing.