Mathematical Function - Lecture Slides | CMSC 106, Study notes of Computer Science

Material Type: Notes; Class: INTRO C PROGRAMMING; Subject: Computer Science; University: University of Maryland; Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 02/13/2009

koofers-user-qji-1
koofers-user-qji-1 🇺🇸

10 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CMSC 106
Lecture Set #7
Set Started:
Tuesday, October 9, 2007
pf3
pf4
pf5

Partial preview of the text

Download Mathematical Function - Lecture Slides | CMSC 106 and more Study notes Computer Science in PDF only on Docsity!

CMSC 106Lecture Set

Set Started:

Tuesday, October 9, 2007



Function definition



Gives a name to a group of statements which can then beexecuted (called) just using that name.



Mathematical functions

sin(x) = y

^

^

^

function's result

+-- argument

| +-- function name



In C, function result is called return value

Simple example functiondefinition:

void

error_msg(void) {

printf("This ");printf("is Bad Input\n");

return;

function

name

= "error_msg"

return type

= nothing

list of parameters

= empty

body

has only three statements

Calling (executing) a function:



general form:



function-name(any arguments)



as a statement: 

printf("Hello,");



or as an expression in assignment: 

ch = getchar();



or as an expression being tested in a

condition:



while (!feof(stdin))

Examples



parameter passing example



return value example



function calling function example