C++ · ОСНОВЫ · LESSON 16

Your command.

Function · about 12 minutes

Learning with progressRead the summary for free. To save the work, log in to the account.
STEP 1

How it works.

The function gives the name to the action. It is written before main and is called inside main.

void hello() {
    cout << "Привет!" << endl;
}

✦ void means there is no answer.

STEP 2

Try to understand.

void means there is no answer.

hello();

✦ Compare this to the first one. Then do the cool job yourself.

IN-CLASS PRACTICE

Type the code yourself

Manually type the program from the sample. So you'll remember commands and brackets.

#include <iostream>
using namespace std;

void hello() {
    cout << "Привет!" << endl;
}

int main() {
    hello();
    return 0;
}
Open the editor for class work
HOMEWORK

Solve it yourself

Create a void cheer() function that outputs «Ура!» and call it from main.

The answer is hidden. Use similar examples from the lesson notes.

Opening up your homework