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

Numbers with a point

double · about 12 minutes

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

How it works.

double stores a fractional number. In the code, the fractional part is separated by a dot.

double price = 2.5;

✦ You can add fractional numbers just like whole numbers.

STEP 2

Try to understand.

You can add fractional numbers just like whole numbers.

double price = 2.5;
cout << price + 1.5 << 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() {
    double price = 2.5;
    cout << price + 1.5 << endl;
    return 0;
}
Open the editor for class work
HOMEWORK

Solve it yourself

Create double length = 1.5 and double width = 2.0. Bring out their work.

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

Opening up your homework