Part 3 functioncalls

Part 3 functioncalls - Function calls You have seen...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Function calls You have seen function calls since high school, like sqrt(25) // square root of 25 . Its value is 5.0 . abs(-7) // absolute value of -7 . Its value is 7 . cos(0) // cosine of angle 0 . It value is 1.0 . min(5, 7) // minimum of 5 and 7 . Its value is 5 . You will learn to write functions in Java later. Here we just look at how to write calls on functions. A function call has the form < function-name > ( < arguments > ) where < arguments > is a list of expressions separated by commas. The first three function calls you see here have one argument. The last function call has two arguments —the expressions 5 and 7 — and they are separ- ated by a comma. You have even seen a function with no arguments: function length (remember the lecture on type String ). Please remember the term argument of a function call. You may see it called the actual parameter . We do not use this terminology because it is confusing, as you will see when we discuss writing functions themselves. A function call is an expression, and you can put one anywhere an expression could be placed, as you can see in this expression: 1 + min(5, 7) * 2
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/07/2008 for the course CS 101 taught by Professor Gries during the Spring '08 term at Cornell.

Page1 / 2

Part 3 functioncalls - Function calls You have seen...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online