Calculate Average


In this example I defined theAvg outside the function which made it global. I defined theAns inside the function and then assigned the results to theAvg as I left the function. Since it is global I can then see it.
Here I am using separate names for the data inside the function and outside the function to maintain the integrity of the data. I am also changing the value of the data after it has been passed.