Simple Math
To perform arithmetic operations on variables and values C++ supports the following arithmetic operators:
Let’s try:
python912345int sum = 10 + 3; // 13int dif = 10 - 3; // 7int mul = 10 * 3; // 30int div = 10 / 3; // 3int mod = 10 % 3; // 1
By division, any remainder was dropped since we assign the result to the int variable which doesn’t contain any decimals.
You can use all operations above to perform calculations on values, variables, or between variable and value:
python9123double a = 32.1 + 13.2; // 45.3double b = a + 25.3; // 45.3 + 25.3 = 70.6double c = a + b; // 70.6 + 45.3 = 115.9
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 2. Розділ 5
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат