0% found this document useful (0 votes)
8 views11 pages

Programming Fundamentals Lecture 3

Understanding Operators

Uploaded by

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

Programming Fundamentals Lecture 3

Understanding Operators

Uploaded by

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

UNDERSTANDING

Programming Fundamentals (CS-106) OPERATORS


What are Operators? 2

 Operators are symbols which informs the compiler to


perform certain operations on two operands present on the
left and right side of the operator
What are Operator types? 3

 Various types of operators in any programming language:


 Assignment (=)
 Mathematical (+, -, *, /)
 Comparison (>, <, ==, !=)
 Logical (&&,||)
 Bit-wise operators (&, |)
Assignment Operator ( = ) 4

 Used to assign a value to a variable

 Syntax:
variable = value

 Examples:
iPhoneCost = 1200
iPhoneCoverCost = 20
Mathematical Operators (+,-,*,/) 5

 Used for carrying out mathematical operations.

 Syntax:
result = variable1 + variable2

 Examples:
totalCost = iPhoneCost + iPhoneCoverCost //1220
monthlyEMI = iPhoneCost / 12 //100
Comparison Operators (>, <, ==, !=) 6

 Used for comparing variables with values or other variables.

 Syntax:
variable > value

 Examples:
If iPhoneCost > 1000
print “It is too expensive!”
Comparison Operators (>, <, ==, !=) 7

If iPhoneCost < 1000


print “I will take it!”

if phoneModel == “Samsung Galaxy Note”


print “I got Android mobile”

If phoneModel != “iPhone”
print “I probably got Android mobile”
Logical Operators (&&, ||) 8

 Used for conditional checks against other variables or


values.

 Also called Conditional operators

 Syntax:
value1 && value2
value1 || value2
Logical Operators (&&, ||) 9

Examples:
If phoneModel == “Samsung” && phoneCost > 1000
print “I got High End Android Mobile”

If phoneModel == “iPhone” || phoneCost > 1000


print “I got an expensive mobile!”

If model == “Samsung” && cost > 100 && cost <400


print “I got a budget Android Mobile”
References 10

 Fundamentals of Programming Languages #3 |


Understanding Operators – YouTube
(CodeWithPraveen)
 Lecture 5 : Practice of Variable and DataTypes
in Urdu |C++ Programing | The Kacs – YouTube
(KACS Learning)
 Lecture 6: How to take input from the user in C++
| in Urdu | Hindi | C++ |The Kacs
(KACS Learning)
Assignment #3 11

 In Dev C++ create a program that uses


conditional operators (given in examples)
mentioned in this lecture:
1. Share source code of your program
2. Share output generated by your program
3. Draw flowchart of your program

Email: [email protected] with Subject: Name/Reg - PF Assignment #3

You might also like