{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CSC_Test_2_Study_Guide_2

CSC_Test_2_Study_Guide_2 - *FUNCTIONS*An array can be...

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

View Full Document Right Arrow Icon
* FUNCTIONS *An array can be passed as an input argument * The simplest function has no return value and has no parameter. *The array length can be specified in the function declaration void abort (void) - void days( int months[12] ) * The next simplest function has a return value but no parameter. *Make sure the passed in array length agrees with formal parameter lengths char getchar (void) - error checking for this occurs at compile time *Can return *Implicit length for the first dimension of a formal parameter is allowed but not for other dimensions - char, short, int, long, long long, float, double, long double - void days( int years[][12]) OK - structs, unions, enumerated constants, void, pointers - void days( int years[10][]) NOT OK * Cannot return arrays or functions, but can return pointers to both. *You can provide an array length as an input parameter to the function * Can only return one value if you need multiple values - void days( int nm, int months[nm] ) - return a struct , use global variables, or pass in pointers. - void days( int ny, int nm, int years[ny][nm] ) * 2 types of parameters or arguments to a function *Arrays are passed BY REFERENCE not by value, updates in the function update the caller’s array - formal or abstract: declared in the function definition *A block is a set of statements delimited by curly braces (e.g. body of a loop) - actual or concrete: variable values passed to the function at run time. *A variable declared outside of any block has global scope
Background image of page 1

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

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

{[ snackBarMessage ]}

Page1 / 2

CSC_Test_2_Study_Guide_2 - *FUNCTIONS*An array can be...

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

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