0% found this document useful (0 votes)
18 views6 pages

University of Engineering and Technology Lahore (NWL Campus)

The document discusses arithmetic and logical operators in C++. It defines addition, subtraction, multiplication and division operators and provides examples of their use. It also explains logical operators like AND and OR and provides truth tables to illustrate their evaluation. The purpose of the document is to explain the basic arithmetic and logical operators in C++ for a computing fundamentals lab report.

Uploaded by

muhammadfawadn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views6 pages

University of Engineering and Technology Lahore (NWL Campus)

The document discusses arithmetic and logical operators in C++. It defines addition, subtraction, multiplication and division operators and provides examples of their use. It also explains logical operators like AND and OR and provides truth tables to illustrate their evaluation. The purpose of the document is to explain the basic arithmetic and logical operators in C++ for a computing fundamentals lab report.

Uploaded by

muhammadfawadn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

UNIVERSITY OF ENGINEERING AND TECHNOLOGY

LAHORE (NWL CAMPUS)

LAB REPORT #5

 SUBJECT COMPUTING FUNDAMENTAL

 SUBMITED BY AMEER HAMZA

 REGISTERATION NO 2023-BME-116

 SUBMITED TO DR. SAMEEN

SUBMISSION DATE __________________________


TABLE OF CONTENT

 Arithmetic logic operators

 Addition , Subtraction , Multiplication , And Division

 Logic Operator i.e ( OR , AND)


C++ Operators

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.

Arithmetic logic operators


Arithmetic operators are used to perform arithmetic operations on variables and data. For
example,

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

The operators +, - and * compute addition, subtraction, and multiplication respectively as we


might have expected.

/ 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.

Figure 2:coding for aadition and


subtradtion and so on ..

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.

Logic Operator i.e ( OR , AND)


Logical operators are used to check whether an expression is true or false. If the expression
is true, it returns 1 whereas if the expression is false, it returns 0.

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,

(a > 3) && (b > 5) evaluates to true


(a > 3) && (b < 5) evaluates to false

(a > 3) || (b > 5) evaluates to true


(a > 3) || (b < 5) evaluates to true
(a < 3) || (b < 5) evaluates to false

!(a < 3) evaluates to true


!(a > 3) evaluates to false

Figure 3: Example og logical operator


(3 != 5) && (3 < 5) evaluates to 1 because both operands (3 != 5) and (3 <
5) are 1 (true).
(3 == 5) && (3 < 5) evaluates to 0 because the operand (3 == 5) is 0 (false).
(3 == 5) && (3 > 5) evaluates to 0 because both operands (3 == 5) and (3 >
5) are 0 (false).
(3 != 5) || (3 < 5) evaluates to 1 because both operands (3 != 5) and (3 <
5) are 1 (true).
(3 != 5) || (3 > 5) evaluates to 1 because the operand (3 != 5) is 1 (true).
(3 == 5) || (3 > 5) evaluates to 0 because both operands (3 == 5) and (3 >
5) are 0 (false).
!(5 == 2) evaluates to 1 because the operand (5 == 2) is 0 (false).
!(5 == 5) evaluates to 0 because the operand (5 == 5) is 1 (true).

LAB TASKS

You might also like