Course Content
C++ Introduction
C++ Introduction
3. Introduction to Operators
4. Introduction to Program Flow
5. Introduction to Functions
Simple Function
Example of the function with arguments from the previous chapter
main
#include <iostream> int func(int a, int b) { return a + b; //the function to sum arguments } int main() { std::cout << "sums the arguments = " << func(5, 7); }
Task
- Create a simple add function (a+b).
- Test the function with x = 5, y = 10.
Task
- Create a simple add function (a+b).
- Test the function with x = 5, y = 10.
Everything was clear?
Section 5. Chapter 5
Simple Function
Example of the function with arguments from the previous chapter
main
#include <iostream> int func(int a, int b) { return a + b; //the function to sum arguments } int main() { std::cout << "sums the arguments = " << func(5, 7); }
Task
- Create a simple add function (a+b).
- Test the function with x = 5, y = 10.
Task
- Create a simple add function (a+b).
- Test the function with x = 5, y = 10.
Everything was clear?
Section 5. Chapter 5
Simple Function
Example of the function with arguments from the previous chapter
main
#include <iostream> int func(int a, int b) { return a + b; //the function to sum arguments } int main() { std::cout << "sums the arguments = " << func(5, 7); }
Task
- Create a simple add function (a+b).
- Test the function with x = 5, y = 10.
Task
- Create a simple add function (a+b).
- Test the function with x = 5, y = 10.
Everything was clear?
Example of the function with arguments from the previous chapter
main
#include <iostream> int func(int a, int b) { return a + b; //the function to sum arguments } int main() { std::cout << "sums the arguments = " << func(5, 7); }
Task
- Create a simple add function (a+b).
- Test the function with x = 5, y = 10.
Section 5. Chapter 5
Switch to desktop for real-world practiceContinue from where you are using one of the options below