Originally Posted By: 3dgs_snake
Code:
var compute_days(var age)
{
   return age * 365.25;
}


You are creating a function that accepts a var argument. This argument will be known as age inside the function(you declared it as so). The functin will return another var resulting from the calculation declared inside your function.

Code:
function main()
{
   var my_age = 33;
   var number_of_days = compute_days(my_age);
   printf("I am %.f days old!",number_of_days);
}


You declare a var named my_age.
You call the function declared above and pass in the my_age variable (Inside the function it will be known as age and will have the value you passed in when you called the function) and put the value inside the number_of_days variable.
Finally, you print it.


Hi 3dgs,

Thanks for your fast reply. I think i got it now. The thing that got me confused is that I think that instead of var compute_days(var age) it should say var compute_days(var my_age).

I don't really get how the computer know its the same thing? or is it?

AND, passing variables, is this a usefull tool? or is it more to make the coding "look good"?

Thank you!

Ibra