Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Simple Function | Introduction to Functions
C++ Introduction
course content

Course Content

C++ Introduction

C++ Introduction

1. Getting Started
2. Variables and Data Types
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

cpp

main

1234567891011
#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
toggle bottom row

Simple Function

Example of the function with arguments from the previous chapter

cpp

main

1234567891011
#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
toggle bottom row

Simple Function

Example of the function with arguments from the previous chapter

cpp

main

1234567891011
#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

cpp

main

1234567891011
#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
We're sorry to hear that something went wrong. What happened?
some-alt