MIS 24053 Lecture Notes - Lecture 15: Function Prototype, Structured Programming

11 views3 pages

Document Summary

A complex problem is often easier to solve by dividing it into several smaller parts, each of which can be solved by itself. These parts are sometimes made into functions in c++. main() then uses these functions to solve the original problem. Functions separate the concept (what is done) from the implementation (how it is done). Functions can be called several times in the same program, allowing the code to be reused. 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. ) For example: definition of a function that computes the absolute value of an integer: int absolute(int x){ if (x >= 0) else. The result of a function call is a value of type return x; return -x; return 0; } while (num!=0){ return x; return -x; }

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents