From the course: C Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Passing arguments to a function

Passing arguments to a function - C Tutorial

From the course: C Essential Training

Start my 1-month free trial

Passing arguments to a function

- [Instructor] Arguments passed to a function must be given a data type, which is set in the function's argument list. In this exercise file, the repeat function expects an integer argument count. Count is used within the function to set a loop. You do not need to re-declare the variable passed within the function. The value of the variable passed is set in the function call here in the main function at lines 15, and again, at line 17. The function sends a chunk of text to output, repeating it as many times as was specified in the argument. The repeat function doesn't return a value, so it's typed as a void function, build and run to see the results. And this is true line. I know these two guys. In this exercise file, the function average consumes three floating point values as its arguments. These values are assigned, within the function, to variables a, b, and c. The average is then computed, and the result…

Contents