function

function - Programming Introduction to Functions g...

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

View Full Document Right Arrow Icon
Introduction to Functions Programming
Background image of page 1

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

View Full DocumentRight Arrow Icon
og Fundamentals I: Introduction to Functions /Slide 2 Introduction to Functions A complex problem is often easier to solve by dividing it into several smaller parts, each of which can be solved by itself. This is called structured programming. These parts are sometimes made into functions in C++. main() then uses these functions to solve the original problem.
Background image of page 2
og Fundamentals I: Introduction to Functions /Slide 3 Advantages of Functions Functions separate the concept (what is done ) from the implementation (how it is done ). Functions make programs easier to understand. Functions can be called several times in the same program, allowing the code to be reused.
Background image of page 3

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

View Full DocumentRight Arrow Icon
og Fundamentals I: Introduction to Functions /Slide 4 C++ Functions C++ allows the use of both internal (user- defined) and external functions. External functions (e.g., abs , ceil , rand , sqrt, etc.) are usually grouped into specialized libraries (e.g., iostream , stdlib , math , etc.)
Background image of page 4
og Fundamentals I: Introduction to Functions /Slide 5 User-Defined Functions C++ programs usually have the following form: // include statements // function prototypes // main() function // function definitions
Background image of page 5

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

View Full DocumentRight Arrow Icon
og Fundamentals I: Introduction to Functions /Slide 6 Function Input and Output
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 16

function - Programming Introduction to Functions g...

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

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