Computer Science Data structures and algorithms Lecture notes, Lecture notes of Data Structures and Algorithms

About data data structures and algorithms Analysis lecture

Typology: Lecture notes

2020/2021

Uploaded on 07/26/2021

bzus-bash
bzus-bash 🇵🇰

4.5

(2)

1 document

1 / 23

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Mr. Saif ur Rehman Khan
MS (Data Science, and
Computer Science)
BS (Computer Science)
Honors:
Certified Android Developer, Research Assistant
E-Mail: saifurrehman.k[email protected]
1
Institute of Southern
Punjab, Multan
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17

Partial preview of the text

Download Computer Science Data structures and algorithms Lecture notes and more Lecture notes Data Structures and Algorithms in PDF only on Docsity!

Mr. Saif ur Rehman Khan MS (Data Science, and Computer Science) BS (Computer Science) Honors: Certified Android Developer, Research Assistant E-Mail: [email protected]

Institute of Southern

Punjab, Multan

Object Oriented of Programming

Lecture#

Operators

Recap

Operators in C++

  • (^) An operator is a symbol which operates on a value or a variable. For example : + is an operator to perform addition.
  • (^) Arithmetic Operators
  • (^) An arithmetic operator is a mathematical function that takes two operands and performs a calculation on them. e.g., Addition, Subtraction etc.
  • (^) Increment and Decrement Operators

Continue…

Assignment Operators

  • (^) C++ programming has two operators increment ++ and decrement -- to change the value of an operand (constant or variable) by 1.
  • (^) Increment ++ increases the value by 1 whereas decrement -- decreases the value by 1.
  • (^) Relational Operators
  • (^) A relational operator checks the relationship between two

operands. If the relation is true, it returns 1; if the relation is

false, it returns value 0.

  • (^) Escape Sequences
  • (^) Sometimes, it is necessary to use characters which cannot be

typed or has special meaning in C programming. For example:

newline(enter), tab, question mark etc. In order to use these

characters, escape sequence is used.

Continue…

Logical Operators

An expression containing logical operator returns either 0 or 1 depending upon whether expression results true or false. Logical operators are commonly used in decision making in C++ programming.

Operator Meaning of Operator

&& Logical AND. True only if all operands are true || Logical OR. True only if either one operands are true ! Logical NOT. True only if the operands is 0

Continue…

Continue…

Conditional Operators

  • (^) The conditional operator works as follows:
  • (^) The first expression conditional Expression is evaluated first. This

expression evaluates to 1 if it's true and evaluates to 0 if it's false.

 If conditional Expression is true, expression1 is evaluated.

 If conditional Expression is false, expression2 is evaluated.

Continue…

  • (^) Here, x is assigned the value of 30 if y is less than 10 and 40 If it is not. We can the try following example −

Continue…

Special Operators

  • (^) sizeof operator The sizeof is an unary operator which returns the size of data (constant, variables, array, structure etc).

Continue…

Continue…

Bitwise Operators During computation, mathematical operations like: addition, subtraction, and division are converted to bit-level which makes processing faster and saves power.

Operator Meaning of Operator

& Bitwise AND | Bitwise OR ^ Bitwise exclusive OR ~ Bitwise Complement << Shift left

Shift right

Continue…

  • (^) Bitwise operator works on bits and perform bit-by-bit operation.
  • (^) The truth tables for &, |, and ^ are as follows −

Continue…

Continue…

  • (^) When the code is compiled and executed, it produces the following result −