Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Division int and double | Introduction
C++ Data Types
course content

Зміст курсу

C++ Data Types

C++ Data Types

1. Introduction
2. Numerical Data Types
3. Text Data Type
4. Other Data Types and Concepts

Division int and double

We will not stop on most operations since they work as expected. Instead, let's look at the reasons behind the incorrect result obtained from the division operation. Those are explained in a video below:

It's not just a problem limited to division. When you use operators such as +, -, *, or / on variables of certain types, the resulting value will have the same type as the operands.

It's important to be mindful of these possibilities and take them into account.

Завдання

  • Calculate and output how many meters in a given number of kilometers (2455).
  • Make sure the output number is float and not integer.

Note

In order to get the correct result, we only need to add . to any of the numbers in division (9/4. or 9./4 or 9./4.).

Завдання

  • Calculate and output how many meters in a given number of kilometers (2455).
  • Make sure the output number is float and not integer.

Note

In order to get the correct result, we only need to add . to any of the numbers in division (9/4. or 9./4 or 9./4.).

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 1. Розділ 3
toggle bottom row

Division int and double

We will not stop on most operations since they work as expected. Instead, let's look at the reasons behind the incorrect result obtained from the division operation. Those are explained in a video below:

It's not just a problem limited to division. When you use operators such as +, -, *, or / on variables of certain types, the resulting value will have the same type as the operands.

It's important to be mindful of these possibilities and take them into account.

Завдання

  • Calculate and output how many meters in a given number of kilometers (2455).
  • Make sure the output number is float and not integer.

Note

In order to get the correct result, we only need to add . to any of the numbers in division (9/4. or 9./4 or 9./4.).

Завдання

  • Calculate and output how many meters in a given number of kilometers (2455).
  • Make sure the output number is float and not integer.

Note

In order to get the correct result, we only need to add . to any of the numbers in division (9/4. or 9./4 or 9./4.).

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 1. Розділ 3
toggle bottom row

Division int and double

We will not stop on most operations since they work as expected. Instead, let's look at the reasons behind the incorrect result obtained from the division operation. Those are explained in a video below:

It's not just a problem limited to division. When you use operators such as +, -, *, or / on variables of certain types, the resulting value will have the same type as the operands.

It's important to be mindful of these possibilities and take them into account.

Завдання

  • Calculate and output how many meters in a given number of kilometers (2455).
  • Make sure the output number is float and not integer.

Note

In order to get the correct result, we only need to add . to any of the numbers in division (9/4. or 9./4 or 9./4.).

Завдання

  • Calculate and output how many meters in a given number of kilometers (2455).
  • Make sure the output number is float and not integer.

Note

In order to get the correct result, we only need to add . to any of the numbers in division (9/4. or 9./4 or 9./4.).

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

We will not stop on most operations since they work as expected. Instead, let's look at the reasons behind the incorrect result obtained from the division operation. Those are explained in a video below:

It's not just a problem limited to division. When you use operators such as +, -, *, or / on variables of certain types, the resulting value will have the same type as the operands.

It's important to be mindful of these possibilities and take them into account.

Завдання

  • Calculate and output how many meters in a given number of kilometers (2455).
  • Make sure the output number is float and not integer.

Note

In order to get the correct result, we only need to add . to any of the numbers in division (9/4. or 9./4 or 9./4.).

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 1. Розділ 3
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt