University of Engineering and Technology Lahore (NWL Campus)
University of Engineering and Technology Lahore (NWL Campus)
LAB REPORT #5
REGISTERATION NO 2023-BME-116
Operators are symbols that perform operations on variables and values. For example, + is an
operator used for addition, while - is an operator used for subtraction.
Here, the + operator is used to add two variables a and b. Similarly there are various other
arithmetic operators in C++.
Figure 1: addition
Addition , Subtraction , Multiplication , And Division
/ Division Operator
Note the operation (a / b) in our program. The / operator is the division operator.
As we can see from the above example, if an integer is divided by another integer, we will get
the quotient. However, if either divisor or dividend is a floating-point number, we will get the
result in decimals.
Here is the coding for the addition and subtraction , multiplication and division. Compile it and the get
out such in this way. Shown in figure below.
% Modulo Operator
The modulo operator % computes the remainder. When a = 9 is divided by b = 4, the remainder
is 1.
In C++, logical operators are commonly used in decision making. To further understand the
logical operators, let's see the following examples,
Suppose,
a = 5
b = 8
Then,
LAB TASKS