CSCD-255
2015-01-16


User-defined Functions — Getting Information back from a Function

A function can return exactly one value to the calling program.  For instance
  length = printf("Hello, world!\n";
will perform the printf operation and then store the value returned in the variable length.

While there are ways to get more than one value, they require using parts of C discussed in Chapters 21, 24, and 27.

First very simple example:  get the value of pi —   PiDemo.txt   PiDemo.c   PiDemo.exe

Next example (borrowing from material in Ch. 23):  constraining the user to enter a value in a range.
IntRange.txt   IntRange.c   IntRange.exe

Example of using multiple printf statements to generate one line of output.  This also demonstrated crediting the source for borrowed code.
MultiPrintDemo.txt   MultiPrintDemo.c   MultiPrintDemo.exe

More complex example:  functions that receive a parameter and return a value.  Specifically, convert between degrees and radians.
Rad_Deg.txt   Rad_Deg.c   Rad_Deg.exe

Homework assignment 1 is available on canvas.  Start working early!  My solution runs to a bit under 200 lines, some of it borrowed from the course website.

The assignment makes reference to this:
http://access.ewu.edu/Student-Financial-Services/Cost-and-Fees/Tuition-Rates.xml