208 Day 11 Functions

208 Day 11 Functions - 4002-208Intro. to Prog. [in C++]Day...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: 4002-208Intro. to Prog. [in C++]Day 11Introduction to FunctionsObjectives•Why use functions?•How to write a function•Function prototype•Random numbers4002-2082Why Functions•To avoid writing the same code more than once – write once, use many times.•Allows a team of programmers to work together on a large project.•Use "divide and conquer" to develop a large program.•Basis of class definition.4002-2083Model of a function4002-2084…0 or 1 return value0 or more parametersNamed block of codeReturn type of functions•Returns exactly one value–Example: toupper, sqrt•Does not return a value–Void function4002-2085Writing a function•Function header–Return type or void if no return type–Name of function–(–0 or more parameters–)•Examples–int doit( )–void printInfo( int x, int y)4002-2086Writing a function (cont.)•Function body–{–Block of code–}•If function has a return type, there must be a return statement–return expression_to_be_returned ;4002-2087Calculate Sales Tax - 1...
View Full Document

This note was uploaded on 03/31/2009 for the course NSSA 4002 208 taught by Professor Niemi during the Spring '09 term at RIT.

Page1 / 16

208 Day 11 Functions - 4002-208Intro. to Prog. [in C++]Day...

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

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