ln021 - Parameters We have discussed different classes of...

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

View Full Document Right Arrow Icon
Parameters We have discussed different classes of variables so far: .!( lobal/static variables - Function local or automatic variables -Dynamic, heap allocated variables However, one important class of variables is still missing parameters Terminology: Example: Java, C, C++ int plus (int a, int b) { return a + b; } int x = plus(1,2); Formal Parameters Actual Parameters Function Definition Function Call Function Body Observation : in function definitions formal parameters act as placeholders for the values of actual parameters. Chap 18
Background image of page 1

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

View Full DocumentRight Arrow Icon
Two Fundamental Questions How is the correspondence between actual and formal parameters established? How is the value of an actual parameter transmitted to a formal parameter?
Background image of page 2
Correspondence Most programming languages use positional parameters ; the first actual parameter is assigned to the first formal parameter, the second actual parameter is assigned to the second formal parameters, etc. int x = plus(1,2); int plus (int a, int b) { return a + b; } 1 1 2 2
Background image of page 3

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

View Full DocumentRight Arrow Icon
Correspondence Some languages such as Ada provide keyword parameters. Example
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/03/2011 for the course CSC 301 taught by Professor Hamel during the Spring '08 term at Rhode Island.

Page1 / 15

ln021 - Parameters We have discussed different classes of...

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

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