Chapter 7 - { int courseScore; getScore(courseScore);

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

View Full Document Right Arrow Icon
Chapter 7 – User-Defined Functions II VOID FUNCTIONS void functionName(void) { statements } ex. printStars (use single cout vs. loop) void functionName( formal parameter list) { statements } print triangle of stars: void printStars (int blanks, int starsInLine) { int count; for (count = 1; count <= blanks; count++) count << “ “; for (count = 1; count <= starsInLine; count++) count << “ *”; cout << endl; } Reference Parameters 1. return more than one value from a function 2. value of actual parameter needs to be changed 3. passing the address would save memory space and time int main ()
Background image of page 1

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

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

Unformatted text preview: { int courseScore; getScore(courseScore); printGrade(courseScore); return 0; } ex. getNumbers, swapValues, printValues [stubs & drivers] Reference parameters and Value-returning functions Scope of an Identifier Local identifiers vs. Global identifiers Side Effects of Global Variables Static and Automatic Variables Void test() { static int x = 0; int y = 10; x += 2; y++; cout << Inside test x = << x << and y = << y << endl; } Function Overloading int larger (int x, int y) char larger (char a, char b) Program to classify numbers...
View Full Document

This note was uploaded on 03/31/2010 for the course CPSC 1301 taught by Professor Khan,s during the Spring '08 term at Columbus State University.

Page1 / 2

Chapter 7 - { int courseScore; getScore(courseScore);

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