# Notes4

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Chapter 4 Functions for All Subtasks Goals: To explore the use of void functions To distinguish between callbyreference and callbyvalue To examine how functions can be nested To introduce testing via stubs and drivers To gain some familiarity with the Visual C++ debugger void Functions When a function returns no value, then it is a void function. void printHeader() { cout &lt;&lt; &quot;RUDIMENTARY INTEGER LIST ANALYSIS AND SUMMARY&quot; &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; &quot;Enter a list of positive integers, ending with -1.&quot; &lt;&lt; endl; cout &lt;&lt; &quot;Afterwards, the maximum, minimum, and mean will be displayed.\n\n&quot;; return; } No Returned Value! int low, int mean) high &lt;&lt; endl; low &lt;&lt; endl; mean &lt;&lt; endl; void outputResults(int high, { cout &lt;&lt; &quot;High Value: &quot; &lt;&lt; cout &lt;&lt; &quot;Low Value: &quot; &lt;&lt; cout &lt;&lt; &quot;Mean Value: &quot; &lt;&lt; return; } CS 140 Most Common Use For void Functions: Pure Output. Page 2 Chapter 4 Calling void Functions void main() { int value; int max = -1; int min = INT_MAX; int total = 0; int count = 0; printHeader(); cout &lt;&lt; &quot;Enter value: &quot;; cin &gt;&gt; value; void Function Call When calling a void function, no return value is expected. while (value &gt;= 0) { max = higher(value, max); min = lower(value, min); total += value; count++; cout &lt;&lt; &quot;Enter value: &quot;; cin &gt;&gt; value; Non-void Function Call Non-void Function Call } outputResults(max, min, average(total, count)); return; } void Function C...
View Full Document

## This note was uploaded on 08/26/2009 for the course CS 140 taught by Professor Staff during the Fall '08 term at Southern Illinois University Edwardsville.

Ask a homework question - tutors are online