Lec 7 Programming Fundamentals (2)
Lec 7 Programming Fundamentals (2)
Lecture 07
Week 05
Ms. Noor-ul-Huda
Senior Lecturer-I
Department of Computer Science
College of Computer Science and Information Systems
[email protected]
Lecture outcomes:
◦ What are Logical operators?
◦ Examples of AND, OR and NOT
◦ Real World Examples
An Operator in Computer
Programming
◦ In computer programing, an operator is a character, symbol, keyword, or
combination of those.
◦ It determines what action gets performed on one or more operands.
oArithmetic operators such as the increment operator(++), which increments the value of the
operand by 1. And the decrement operator(--), which decrements the value of the operand by 1.
oLogical operators like the NOT(!) operator. This operator reverses the logical value of the
operand – it changes true to false and false to true.
oBitwise operators like the NOT(~) operator, which changes each 0 bit to 1 and each 1 bit to 0.
Binary operators
oBinary operators operate on two operands.
oSome of the binary operators in C are:
oArithmetic operators (+, -, *, /, %). These operators perform mathematical calculations on
numerical data such as addition, subtraction, multiplication, division, and finding the remainder.
oEquality/Relational operators (==, !=, >, <, >=, <=). These operators compare two values and
determine if one operand is greater than, less than, equal to, or not equal to the other operand.
oLogical/Conditional operators such as the AND(&&) and OR(||) operators.
oBitwise operators ((&, |, ^, <<, >>), which treat data items as a sequence of bits (that is, 0s and
1s).
oAssignment operators (=, +=, -=, *=, /=, %=), which assign a specific value to a variable.
The Ternary operator
oThe Ternary operator (?:) operates on three operands. The general syntax looks something
similar to the following: