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.

Solution: Passing values

Solution: Passing values - C Tutorial

From the course: C Essential Training

Start my 1-month free trial

Solution: Passing values

(upbeat music) - [Instructor] For my solution, here is my line function. The function has two arguments, integer length and character c. Within the function, integer variable a is used as a looping variable specifically at line seven. It loops from zero to the value, length which is the number passed. And the loop's statement is putchar, which outputs the character passed. I added a putchar function here at line nine, in order to ensure that the output appears on a line by itself. Build and Run, and there's the line. The beauty of functions like this is that you can specify a line of any length or any character. Just set the proper arguments and the function does the work. So down here in the main function, you could add another line function. Say, line with 20 and do dollar signs. Save this change, Build and Run, and you can see the flexibility of the line function and the value of having such arguments.…

Contents