Problem using DC Motors in conjunction with sonar sensors

Why do you have 3 nearly identical functions, for measuring distance? Learn about passing arguments to functions.

Why does each function return a global variable's value? Why do you then overwrite the global variable with the same value that it had?