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

Count the purchases.

+, * and brackets · about 12 minutes

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

How it works.

Numbers can be added by + and multiplied by *. Brackets help you choose order.

int total = 3 * 4;

✦ The result can be stored in int.

STEP 2

Try to understand.

The result can be stored in int.

int price = 4;
int count = 3;
cout << price * count << endl;

✦ 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;

int main() {
    int price = 4;
    int count = 3;
    cout << price * count << endl;
    return 0;
}
Open the editor for class work
HOMEWORK

Solve it yourself

Create int price = 5 and int count = 4. Save the work in int total and output total.

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

Opening up your homework