Lec_10 Functions in C++ PDF
Document Details
Uploaded by SmoothestNeptune6362
Zagazig University
Tags
Summary
Lecture notes on functions in C++. The document details functions in C++ programming, explaining concepts like procedures, methods, subroutines and the divide-and-conquer approach.
Full Transcript
Functions in C++ Lecture 10 Write a C++ program to read three numbers from the user to print their factorial. Function ▪ A function is a collection of statements that performs a specific task. ▪ Also called procedure or methods or subroutine. ▪ A program may be broken up into...
Functions in C++ Lecture 10 Write a C++ program to read three numbers from the user to print their factorial. Function ▪ A function is a collection of statements that performs a specific task. ▪ Also called procedure or methods or subroutine. ▪ A program may be broken up into small manageable functions (divide-and-conquer). ▪ Every C++ program has at least one function, which is main(). Function ▪ Instead of writing one long function that contains all of the statements to solve a problem, several small functions that each solve a specific part of the problem can be written. ▪ These small functions can be executed in the desired order to solve the problem. The program has one long, complex function containing all of the statements to solve a problem. The problem has been divided into smaller problems, each of which is handled by a separate function. #include using namespace std; int main() { cout