Generating Arguments in Functions

Hello! I need some help with functions.
My teacher has asked,

“Write a function named distance that accepts a vehicle’s speed and time as arguments, and
returns the distance the vehicle has traveled.”

I am able to create functions with the double format, return values, but I am not sure how to generate arguments in functions. Please help!

1 Like

Arguments here is a different word for parameters.

So this is your function header :

float distance (float speed, float time){


You don’t “generate arguments” but you return the result based on them.

In the function calculate the distance and return it. You could get the speed in meters per second and the time in seconds.

You call the function from setup() with println(distance (30,10));

And welcome to the forum!

Great to have you here!

Warm regards,


1 Like

Thank you! This is really helpful.

1 Like