Trying to measure distance using an ultrasound sensor
You have declared int distance outside of any method. That means it's available from all methods. Some people call it a global variable.

However, you have a method int distancefonction(int dt, int distance) which receives int distance as a parameter. This results in an ambiguity: if you refer to distance within the method like

distance = 0.034/2*dt;


should this now refer to the parameter distance or the global variable distance? 

The answer is: you can't decide. The C/C++ standard has decided for you and the answer is: the parameter will take precedence and thus hide the global variable. This thing is also called "shadowing".

What does it actually mean?


The global variable distance has an undefined value at the start of the program. Let's assume the value is 0.
distancefonction() is called, passing distance as a parameter. This will create a copy of the value 0 on the stack.
the function will calculate the distance and update the variable on the stack.
The Serial.println() statement within the function accesses the variable on the stack and will print the correct distance.
Once the function is complete, the code in loop() will access the global variable distance, which still has the old value, because only a copy has been updated.


What is the solution?

Of course there are several solutions.


The simplest fix is probably to remove the parameter int distance from distancefonction. Thus the function will not receive a copy and instead operate on the global variable. 
Another solution is to let distancefonction return the actual distance. The method signature already indicates that you wanted to return a value: the intfrom int distancefunction(...) says that. At the moment, the function does not return anything. You could write return distance; at the end. This approach could eliminate the global variable completely.