TAILIEUCHUNG - Chapter 3 Function Basics

Transfers control back to "calling" function For return type other than void, MUST have return statement Typically the LAST statement in function definition return statement optional for void functions. | Chapter 3 Function Basics Learning Objectives Predefined Functions Those that return a value and those that don’t Programmer-defined Functions Defining, Declaring, Calling Recursive Functions Scope Rules Local variables Global constants and global variables Blocks, nested scopes Introduction to Functions Building Blocks of Programs Other terminology in other languages: Procedures, subprograms, methods In C++: functions I-P-O Input – Process – Output Basic subparts to any program Use functions for these "pieces" Predefined Functions Libraries full of functions for our use! Two types: Those that return a value Those that do not (void) Must "#include" appropriate library ., , (Original "C" libraries) (for cout, cin) Using Predefined Functions Math functions very plentiful Found in library Most return a value (the "answer") Example: theRoot = sqrt(); Components: sqrt = name of library function theRoot = variable used to assign "answer" to =

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.