Concept
How do C functions return values to the calling function?
ComputerScienceOne / Void Functions
"18.1. Defining & Using Functions\n\ndouble getDistance(double x1, double y1, double x2, double y2) {\n\ndouble xDiff = (x1-x2);\n\ndouble yDiff = (y1-y2);\n\nreturn sqrt( xDiff * xDiff + yDiff * yDiff);\n\n}\n\ndouble getMonthlyPayment(double principle, double apr, int terms) {\n\ndouble rate = (apr / 12.0);\n\ndouble payment = (principle * rate) / (1-pow(1+rate, -terms));\n\nreturn payment;\n\n}\n\nThe keyword return is used to specify the value that is returned to the calling function."
Related Ideas
- What happens when a PHP function does not return a value?ComputerScienceOne · Calling Functions
- How do you call a function in C?ComputerScienceOne · Calling Functions
- How do you declare functions and specify their return values in PHP?ComputerScienceOne · Declaring Functions
- How do functions work in programming languages?ComputerScienceOne · Functions
- How do you call functions in C?ComputerScienceOne · Organizing Functions