Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Arithmetic Operations | 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

Arithmetic Operations

Let's start with a very basics. But don't skip this section because even here you might find something usefull that then will save you hours of researching.

Setting the precision

As you already should know you can perform basic data manipulation using arithmetic operators such as addition (+), subtraction (-), division (/), and multiplication (*). Additionally, the modulus operator (%) calculates the remainder of a division.

cpp

main

copy
123456789
#include <iostream> #include <iomanip> int main() { // Uncomment to see the difference // std::cout << std::fixed; std::cout << std::setprecision(5) << 15.125 * 0.8309 << std::endl; }

In the example above, floating-point results are sometimes obtained during calculations. You can manage the precision of these results using std::setprecision and std::fixed to control how setprecision functions.

Note

Without std::fixed, std::setprecision controls the total number of digits displayed, including both before and after the decimal points. With std::fixed, the number is displayed in fixed-point notation, keeping the decimal point in a fixed position.

Завдання

  • Include <iomanip> to be able to set precision.
  • Follow the comments to set a precision.
  • Calculate and output the equivalent of 5 miles in kilometers rounding to one decimal place.

Note

To convert 5 miles to kilometers, you would multiply the number of miles by the conversion factor (1.60934).

Once you've completed this task, click the button below the code to check your solution.

Завдання

  • Include <iomanip> to be able to set precision.
  • Follow the comments to set a precision.
  • Calculate and output the equivalent of 5 miles in kilometers rounding to one decimal place.

Note

To convert 5 miles to kilometers, you would multiply the number of miles by the conversion factor (1.60934).

Once you've completed this task, click the button below the code to check your solution.

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

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

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

Arithmetic Operations

Let's start with a very basics. But don't skip this section because even here you might find something usefull that then will save you hours of researching.

Setting the precision

As you already should know you can perform basic data manipulation using arithmetic operators such as addition (+), subtraction (-), division (/), and multiplication (*). Additionally, the modulus operator (%) calculates the remainder of a division.

cpp

main

copy
123456789
#include <iostream> #include <iomanip> int main() { // Uncomment to see the difference // std::cout << std::fixed; std::cout << std::setprecision(5) << 15.125 * 0.8309 << std::endl; }

In the example above, floating-point results are sometimes obtained during calculations. You can manage the precision of these results using std::setprecision and std::fixed to control how setprecision functions.

Note

Without std::fixed, std::setprecision controls the total number of digits displayed, including both before and after the decimal points. With std::fixed, the number is displayed in fixed-point notation, keeping the decimal point in a fixed position.

Завдання

  • Include <iomanip> to be able to set precision.
  • Follow the comments to set a precision.
  • Calculate and output the equivalent of 5 miles in kilometers rounding to one decimal place.

Note

To convert 5 miles to kilometers, you would multiply the number of miles by the conversion factor (1.60934).

Once you've completed this task, click the button below the code to check your solution.

Завдання

  • Include <iomanip> to be able to set precision.
  • Follow the comments to set a precision.
  • Calculate and output the equivalent of 5 miles in kilometers rounding to one decimal place.

Note

To convert 5 miles to kilometers, you would multiply the number of miles by the conversion factor (1.60934).

Once you've completed this task, click the button below the code to check your solution.

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

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

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

Arithmetic Operations

Let's start with a very basics. But don't skip this section because even here you might find something usefull that then will save you hours of researching.

Setting the precision

As you already should know you can perform basic data manipulation using arithmetic operators such as addition (+), subtraction (-), division (/), and multiplication (*). Additionally, the modulus operator (%) calculates the remainder of a division.

cpp

main

copy
123456789
#include <iostream> #include <iomanip> int main() { // Uncomment to see the difference // std::cout << std::fixed; std::cout << std::setprecision(5) << 15.125 * 0.8309 << std::endl; }

In the example above, floating-point results are sometimes obtained during calculations. You can manage the precision of these results using std::setprecision and std::fixed to control how setprecision functions.

Note

Without std::fixed, std::setprecision controls the total number of digits displayed, including both before and after the decimal points. With std::fixed, the number is displayed in fixed-point notation, keeping the decimal point in a fixed position.

Завдання

  • Include <iomanip> to be able to set precision.
  • Follow the comments to set a precision.
  • Calculate and output the equivalent of 5 miles in kilometers rounding to one decimal place.

Note

To convert 5 miles to kilometers, you would multiply the number of miles by the conversion factor (1.60934).

Once you've completed this task, click the button below the code to check your solution.

Завдання

  • Include <iomanip> to be able to set precision.
  • Follow the comments to set a precision.
  • Calculate and output the equivalent of 5 miles in kilometers rounding to one decimal place.

Note

To convert 5 miles to kilometers, you would multiply the number of miles by the conversion factor (1.60934).

Once you've completed this task, click the button below the code to check your solution.

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

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

Let's start with a very basics. But don't skip this section because even here you might find something usefull that then will save you hours of researching.

Setting the precision

As you already should know you can perform basic data manipulation using arithmetic operators such as addition (+), subtraction (-), division (/), and multiplication (*). Additionally, the modulus operator (%) calculates the remainder of a division.

cpp

main

copy
123456789
#include <iostream> #include <iomanip> int main() { // Uncomment to see the difference // std::cout << std::fixed; std::cout << std::setprecision(5) << 15.125 * 0.8309 << std::endl; }

In the example above, floating-point results are sometimes obtained during calculations. You can manage the precision of these results using std::setprecision and std::fixed to control how setprecision functions.

Note

Without std::fixed, std::setprecision controls the total number of digits displayed, including both before and after the decimal points. With std::fixed, the number is displayed in fixed-point notation, keeping the decimal point in a fixed position.

Завдання

  • Include <iomanip> to be able to set precision.
  • Follow the comments to set a precision.
  • Calculate and output the equivalent of 5 miles in kilometers rounding to one decimal place.

Note

To convert 5 miles to kilometers, you would multiply the number of miles by the conversion factor (1.60934).

Once you've completed this task, click the button below the code to check your solution.

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