Welcome to Nesso Academy's Chapter 3, focusing on operators in C++. This chapter will cover various types of operators, specifically starting with arithmetic operators.
Introduction to Arithmetic Operators
int
, float
, and double
.Unary Arithmetic Operators
int val = -4;
cout << +val; // Output: -4
cout << -val; // Output: 4
Binary Arithmetic Operators
+
): 10 + 3
results in 13
.-
): 10 - 3
results in 7
.*
): 10 * 3
results in 30
./
): 10 / 3
results in 3
(integer division).%
): 10 % 3
results in 1
.Important Points about Arithmetic Operators
12 / 5.0 // Output: 2.4
12 / 5 // Output: 2
0.0
: May result in INF
(infinity) or NaN
(not a number), depending on system representation (IEEE 754).This concludes the lecture on arithmetic operators in C++. Thank you for attending, and see you in the next session!