课程: Complete Guide to C Programming Foundations

今天就学习课程吧!

今天就开通帐号,24,100 门业界名师课程任您挑!

Chapter solution: Write the functions

Chapter solution: Write the functions

(upbeat music) - [Instructor] The code requires you to write four functions which appear here in the main function, add, subtract, multiply, and then divide here in the printf statement. The first three functions are similar, they accept two integer arguments and they return nothing. The divide function is in the printf statement and it returns a value, but it doesn't output any text. The value must correspond to the %f placeholder here. I'll set the functions atop the source code file, which avoids me having to write the prototypes. First, I'll do the add function. The add function is a void function because it returns no values, but it does output a string according to the instructions. This is the format with a math as the third argument. You could perform the math as its own statement, but it would require an additional variable, this is kind of a shortcut way to do it. The subtract and multiply functions are similar, so I can copy and paste and then edit the signs. Here you see…

内容