SlideShare a Scribd company logo
CSC 103
Lecture 5
Introduction to Computers and Programming
Evaluate yourself!
2
 Point out the errors, if any, in the following C statements:
(a) int = 314.562 * 150 ;
(b) name = ‘Ajay’ ;
(c) varchar = ‘3’ ;
(d) 3.14 * r * r * h = vol_of_cyl ;
(e) k = ( a * b ) ( c + ( 2.5a + b ) ( d + e ) ;
(f) m_inst = rate of interest * amount in rs ;
Operators
 Operators are symbols that can be used to perform
certain calculations. They are always in between
expressions.
 Operators can be classified according to
 The number of their operands
 Unary (one operand)
 Binary (two operands)
 The type of their operands and of their output
 Arithmetic
 Relational
 Logical
 Bitwise
3
Assignment operator: =
 Binary operator used to assign a value to a variable.
 Its left operand is the destination variable
 Its right operand is an expression.
int var;
var = 10;
COPY
4
Arithmetic operators
 They operate on numbers and the result is a number.
 The type of the result depends on the types of the
operands.
 If the types of the operands differ, one is "promoted"
to other.
 The "smaller" type is promoted to the "larger" one.
char  int  float  double
5
Arithmetic operators: +, *
 + is the addition operator
 * is the multiplication operator
 They are both binary
6
Arithmetic operator: 
 This operator has two meanings:
 subtraction operator (binary)
 negation operator (unary)
e.g. 31 - 2
e.g. -10
7
Arithmetic operator: /
 Division operator
 CAREFUL! The result of integer division is an integer:
e.g. 5 / 2 is 2, not 2.5
8
Arithmetic operator: %
 The modulus (remainder) operator.
 It computes the remainder after the first operand is
divided by the second
 works only with integers
 It is useful for making cycles of numbers:
 For an int variable x :
if x is: 0 1 2 3 4 5 6 7 8
x%3 is: 0 1 2 0 1 2 0 1 2
e.g. 5 % 2 is 1,
6 % 2 is 0
9
An Example
10
#include <stdio.h>
void main (void)
{
int a = 25, b = 5, c = 10, d = 7;
printf ("a %% b = %in", a % b);
printf ("a %% c = %in", a % c);
printf ("a %% d = %in", a % d);
printf ("a / d * d + a %% d = %in",
a / d * d + a % d);
}
Output:
a % b = 0
a % c = 5
a % d = 4
a / d * d + a % d = 25
Using Arithmetic Operators
11
#include <stdio.h>
void main (void)
{
int a = 100, b = 2, c = 25, d = 4,result;
result = a - b; // subtraction
printf ("a - b = %in", result);
result = b * c; // multiplication
printf ("b * c = %in", result);
result = a / c; // division
printf ("a / c = %in", result);
result = a + b * c; // precedence
printf ("a + b * c = %in", result);
printf ("a * b + c * d = %in", a * b + c * d);
}
Output:
a - b = 98
b * c = 50
a / c = 4
a + b * c = 150
a * b + c * d = 300
Relational operators
 These perform comparisons and the result is what is called a
Boolean: a value TRUE or FALSE
 FALSE is represented by 0; anything else is TRUE
 The relational operators are:
 < (less than)
 <= (less than or equal to)
 > (greater than)
 >= (greater than or equal to)
 == (equal to)
 != (not equal to)
12
Logical operators
 These have boolean operands and the result is also a
boolean.
 The basic boolean operators are:
 && (logical AND)
 || (logical OR)
 ! (logical NOT) -- unary
13
Special assignment operators
 write a += b; instead of a = a + b;
 write a -= b; instead of a = a - b;
 write a *= b; instead of a = a * b;
 write a /= b; instead of a = a / b;
 write a %= b; instead of a = a % b;
14
Special assignment operators
 Increment, decrement operators: ++, --
 Instead of a = a + 1 you can write a++ or ++a
 Instead of a = a - 1 you can write a-- or --a
 What is the difference?
num = 10;
ans = num++;
num = 10;
ans = ++num;
First increment num,
then assign num to ans.
In the end,
num = 11
ans = 11
First assign num to ans,
then increment num.
In the end,
num =11
ans = 10
post-increment pre-increment
15
Operator Hierarchy
16
This expression
z = a * b + c / d
is same as;
z = (a * b) + (c / d)
Solve Following Expressions;
17
&
Solution
18
In C Language
19
Associativity of Operators
20
 We can have same priority operators in an expression
 Then we check associativity of operators
 There are two rules:
 Left to Right
 means that the operators are performed from left to right
 Right to Left
 means that the operators are performed from right to left

More Related Content

What's hot

Operator of C language
Operator of C languageOperator of C language
Operator of C language
Kritika Chauhan
 
Operators in C/C++
Operators in C/C++Operators in C/C++
Operators in C/C++
Shobi P P
 
2. operators in c
2. operators in c2. operators in c
2. operators in c
amar kakde
 
Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzation
Kaushal Patel
 
Increment and Decrement operators in C++
Increment and Decrement operators in C++Increment and Decrement operators in C++
Increment and Decrement operators in C++
Neeru Mittal
 
Types of operators in C
Types of operators in CTypes of operators in C
Types of operators in C
Prabhu Govind
 
Basic c operators
Basic c operatorsBasic c operators
Basic c operators
Anuja Lad
 
Theory3
Theory3Theory3
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++
sunny khan
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
programming9
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++
Online
 
C operators
C operatorsC operators
C operators
GPERI
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
tanmaymodi4
 
C operators
C operatorsC operators
C operators
Rupanshi rawat
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
Manoj Tyagi
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
Neeru Mittal
 
Relational operators In C language (By: Shujaat Abbas)
Relational operators In C language (By: Shujaat Abbas)Relational operators In C language (By: Shujaat Abbas)
Relational operators In C language (By: Shujaat Abbas)
Shujaat Abbas
 
Variables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detailVariables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detail
gourav kottawar
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
Rohit Shrivastava
 

What's hot (19)

Operator of C language
Operator of C languageOperator of C language
Operator of C language
 
Operators in C/C++
Operators in C/C++Operators in C/C++
Operators in C/C++
 
2. operators in c
2. operators in c2. operators in c
2. operators in c
 
Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzation
 
Increment and Decrement operators in C++
Increment and Decrement operators in C++Increment and Decrement operators in C++
Increment and Decrement operators in C++
 
Types of operators in C
Types of operators in CTypes of operators in C
Types of operators in C
 
Basic c operators
Basic c operatorsBasic c operators
Basic c operators
 
Theory3
Theory3Theory3
Theory3
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++
 
C operators
C operatorsC operators
C operators
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
C operators
C operatorsC operators
C operators
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Relational operators In C language (By: Shujaat Abbas)
Relational operators In C language (By: Shujaat Abbas)Relational operators In C language (By: Shujaat Abbas)
Relational operators In C language (By: Shujaat Abbas)
 
Variables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detailVariables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detail
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
 

Similar to ICP - Lecture 5

C Operators and Control Structures.pptx
C Operators and Control Structures.pptxC Operators and Control Structures.pptx
C Operators and Control Structures.pptx
ramanathan2006
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
Saranya saran
 
C Operators and Control Structures.pdf
C Operators and Control Structures.pdfC Operators and Control Structures.pdf
C Operators and Control Structures.pdf
MaryJacob24
 
PROGRAMMING IN C - Operators.pptx
PROGRAMMING IN C - Operators.pptxPROGRAMMING IN C - Operators.pptx
PROGRAMMING IN C - Operators.pptx
Nithya K
 
C - programming - Ankit Kumar Singh
C - programming - Ankit Kumar Singh C - programming - Ankit Kumar Singh
C - programming - Ankit Kumar Singh
AnkitSinghRajput35
 
C programming session 02
C programming session 02C programming session 02
C programming session 02Dushmanta Nath
 
C Programming
C ProgrammingC Programming
C Programming
Raj vardhan
 
C operators
C operators C operators
C operators
AbiramiT9
 
COM1407: C Operators
COM1407: C OperatorsCOM1407: C Operators
COM1407: C Operators
Hemantha Kulathilake
 
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTESUnit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
LeahRachael
 
Operators
OperatorsOperators
Operators
VijayaLakshmi506
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c language
Tanmay Modi
 
Dti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpressionDti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpressionalish sha
 
C language basics
C language basicsC language basics
C language basics
Milind Deshkar
 
Operators in c by anupam
Operators in c by anupamOperators in c by anupam
Operators in c by anupam
CGC Technical campus,Mohali
 
C programming(Part 1)
C programming(Part 1)C programming(Part 1)
C programming(Part 1)
SURBHI SAROHA
 
ppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operatorsppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operators
Amrinder Sidhu
 
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
Muhammad Hammad Waseem
 
operators.pptx
operators.pptxoperators.pptx
operators.pptx
ruchisuru20001
 

Similar to ICP - Lecture 5 (20)

C Operators and Control Structures.pptx
C Operators and Control Structures.pptxC Operators and Control Structures.pptx
C Operators and Control Structures.pptx
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
 
C Operators and Control Structures.pdf
C Operators and Control Structures.pdfC Operators and Control Structures.pdf
C Operators and Control Structures.pdf
 
PROGRAMMING IN C - Operators.pptx
PROGRAMMING IN C - Operators.pptxPROGRAMMING IN C - Operators.pptx
PROGRAMMING IN C - Operators.pptx
 
C - programming - Ankit Kumar Singh
C - programming - Ankit Kumar Singh C - programming - Ankit Kumar Singh
C - programming - Ankit Kumar Singh
 
C programming session 02
C programming session 02C programming session 02
C programming session 02
 
C Programming
C ProgrammingC Programming
C Programming
 
C operators
C operators C operators
C operators
 
COM1407: C Operators
COM1407: C OperatorsCOM1407: C Operators
COM1407: C Operators
 
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTESUnit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
 
Operators
OperatorsOperators
Operators
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c language
 
Dti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpressionDti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpression
 
C language basics
C language basicsC language basics
C language basics
 
Operators in c by anupam
Operators in c by anupamOperators in c by anupam
Operators in c by anupam
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
 
C programming(Part 1)
C programming(Part 1)C programming(Part 1)
C programming(Part 1)
 
ppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operatorsppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operators
 
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
 
operators.pptx
operators.pptxoperators.pptx
operators.pptx
 

More from Hassaan Rahman

Lecture#12 preservation of hadees
Lecture#12 preservation of hadeesLecture#12 preservation of hadees
Lecture#12 preservation of hadeesHassaan Rahman
 
Isl. lecture#11 ahadees
Isl. lecture#11 ahadeesIsl. lecture#11 ahadees
Isl. lecture#11 ahadeesHassaan Rahman
 
Isl. lecture#10 the miracle of the holy qura'n
Isl. lecture#10 the miracle of the holy qura'nIsl. lecture#10 the miracle of the holy qura'n
Isl. lecture#10 the miracle of the holy qura'nHassaan Rahman
 
Isl. lecture#9 compilation in the time of hazrat usman (r.a.)
Isl. lecture#9 compilation in the time of hazrat usman (r.a.)Isl. lecture#9 compilation in the time of hazrat usman (r.a.)
Isl. lecture#9 compilation in the time of hazrat usman (r.a.)Hassaan Rahman
 
Isl. lecture#8 the holy qura'n
Isl. lecture#8 the holy qura'nIsl. lecture#8 the holy qura'n
Isl. lecture#8 the holy qura'nHassaan Rahman
 
Isl. lecture#7 risalat
Isl. lecture#7 risalatIsl. lecture#7 risalat
Isl. lecture#7 risalatHassaan Rahman
 
ECA - Source Transformation
ECA - Source TransformationECA - Source Transformation
ECA - Source TransformationHassaan Rahman
 
Isl. lecture#6 effect of tawheed
Isl. lecture#6 effect of tawheedIsl. lecture#6 effect of tawheed
Isl. lecture#6 effect of tawheedHassaan Rahman
 
Isl. lecture#5 tawheed
Isl. lecture#5 tawheedIsl. lecture#5 tawheed
Isl. lecture#5 tawheedHassaan Rahman
 
Electric Circuit - Lecture 04
Electric Circuit - Lecture 04Electric Circuit - Lecture 04
Electric Circuit - Lecture 04Hassaan Rahman
 
Isl. lecture#3 need of islam
Isl. lecture#3 need of islamIsl. lecture#3 need of islam
Isl. lecture#3 need of islamHassaan Rahman
 
Lab 02 Resistor color coding and ohms law
Lab 02   Resistor color coding and ohms lawLab 02   Resistor color coding and ohms law
Lab 02 Resistor color coding and ohms lawHassaan Rahman
 

More from Hassaan Rahman (20)

Step natural
Step naturalStep natural
Step natural
 
Lecture#12 preservation of hadees
Lecture#12 preservation of hadeesLecture#12 preservation of hadees
Lecture#12 preservation of hadees
 
Isl. lecture#11 ahadees
Isl. lecture#11 ahadeesIsl. lecture#11 ahadees
Isl. lecture#11 ahadees
 
Isl. lecture#10 the miracle of the holy qura'n
Isl. lecture#10 the miracle of the holy qura'nIsl. lecture#10 the miracle of the holy qura'n
Isl. lecture#10 the miracle of the holy qura'n
 
Isl. lecture#9 compilation in the time of hazrat usman (r.a.)
Isl. lecture#9 compilation in the time of hazrat usman (r.a.)Isl. lecture#9 compilation in the time of hazrat usman (r.a.)
Isl. lecture#9 compilation in the time of hazrat usman (r.a.)
 
Circuits
CircuitsCircuits
Circuits
 
Isl. lecture#8 the holy qura'n
Isl. lecture#8 the holy qura'nIsl. lecture#8 the holy qura'n
Isl. lecture#8 the holy qura'n
 
Isl. lecture#7 risalat
Isl. lecture#7 risalatIsl. lecture#7 risalat
Isl. lecture#7 risalat
 
Thev norton eq
Thev norton eqThev norton eq
Thev norton eq
 
ECA - Source Transformation
ECA - Source TransformationECA - Source Transformation
ECA - Source Transformation
 
Isl. lecture#6 effect of tawheed
Isl. lecture#6 effect of tawheedIsl. lecture#6 effect of tawheed
Isl. lecture#6 effect of tawheed
 
Isl. lecture#5 tawheed
Isl. lecture#5 tawheedIsl. lecture#5 tawheed
Isl. lecture#5 tawheed
 
Circuits5
Circuits5Circuits5
Circuits5
 
Electric Circuit - Lecture 04
Electric Circuit - Lecture 04Electric Circuit - Lecture 04
Electric Circuit - Lecture 04
 
ECA - Lecture 03
ECA - Lecture 03ECA - Lecture 03
ECA - Lecture 03
 
Isl. lecture#4 islam
Isl. lecture#4 islamIsl. lecture#4 islam
Isl. lecture#4 islam
 
Isl. lecture#3 need of islam
Isl. lecture#3 need of islamIsl. lecture#3 need of islam
Isl. lecture#3 need of islam
 
ICP - Lecture 7 and 8
ICP - Lecture 7 and 8ICP - Lecture 7 and 8
ICP - Lecture 7 and 8
 
ICP - Lecture 6
ICP - Lecture 6ICP - Lecture 6
ICP - Lecture 6
 
Lab 02 Resistor color coding and ohms law
Lab 02   Resistor color coding and ohms lawLab 02   Resistor color coding and ohms law
Lab 02 Resistor color coding and ohms law
 

Recently uploaded

Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 

Recently uploaded (20)

Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 

ICP - Lecture 5

  • 1. CSC 103 Lecture 5 Introduction to Computers and Programming
  • 2. Evaluate yourself! 2  Point out the errors, if any, in the following C statements: (a) int = 314.562 * 150 ; (b) name = ‘Ajay’ ; (c) varchar = ‘3’ ; (d) 3.14 * r * r * h = vol_of_cyl ; (e) k = ( a * b ) ( c + ( 2.5a + b ) ( d + e ) ; (f) m_inst = rate of interest * amount in rs ;
  • 3. Operators  Operators are symbols that can be used to perform certain calculations. They are always in between expressions.  Operators can be classified according to  The number of their operands  Unary (one operand)  Binary (two operands)  The type of their operands and of their output  Arithmetic  Relational  Logical  Bitwise 3
  • 4. Assignment operator: =  Binary operator used to assign a value to a variable.  Its left operand is the destination variable  Its right operand is an expression. int var; var = 10; COPY 4
  • 5. Arithmetic operators  They operate on numbers and the result is a number.  The type of the result depends on the types of the operands.  If the types of the operands differ, one is "promoted" to other.  The "smaller" type is promoted to the "larger" one. char  int  float  double 5
  • 6. Arithmetic operators: +, *  + is the addition operator  * is the multiplication operator  They are both binary 6
  • 7. Arithmetic operator:   This operator has two meanings:  subtraction operator (binary)  negation operator (unary) e.g. 31 - 2 e.g. -10 7
  • 8. Arithmetic operator: /  Division operator  CAREFUL! The result of integer division is an integer: e.g. 5 / 2 is 2, not 2.5 8
  • 9. Arithmetic operator: %  The modulus (remainder) operator.  It computes the remainder after the first operand is divided by the second  works only with integers  It is useful for making cycles of numbers:  For an int variable x : if x is: 0 1 2 3 4 5 6 7 8 x%3 is: 0 1 2 0 1 2 0 1 2 e.g. 5 % 2 is 1, 6 % 2 is 0 9
  • 10. An Example 10 #include <stdio.h> void main (void) { int a = 25, b = 5, c = 10, d = 7; printf ("a %% b = %in", a % b); printf ("a %% c = %in", a % c); printf ("a %% d = %in", a % d); printf ("a / d * d + a %% d = %in", a / d * d + a % d); } Output: a % b = 0 a % c = 5 a % d = 4 a / d * d + a % d = 25
  • 11. Using Arithmetic Operators 11 #include <stdio.h> void main (void) { int a = 100, b = 2, c = 25, d = 4,result; result = a - b; // subtraction printf ("a - b = %in", result); result = b * c; // multiplication printf ("b * c = %in", result); result = a / c; // division printf ("a / c = %in", result); result = a + b * c; // precedence printf ("a + b * c = %in", result); printf ("a * b + c * d = %in", a * b + c * d); } Output: a - b = 98 b * c = 50 a / c = 4 a + b * c = 150 a * b + c * d = 300
  • 12. Relational operators  These perform comparisons and the result is what is called a Boolean: a value TRUE or FALSE  FALSE is represented by 0; anything else is TRUE  The relational operators are:  < (less than)  <= (less than or equal to)  > (greater than)  >= (greater than or equal to)  == (equal to)  != (not equal to) 12
  • 13. Logical operators  These have boolean operands and the result is also a boolean.  The basic boolean operators are:  && (logical AND)  || (logical OR)  ! (logical NOT) -- unary 13
  • 14. Special assignment operators  write a += b; instead of a = a + b;  write a -= b; instead of a = a - b;  write a *= b; instead of a = a * b;  write a /= b; instead of a = a / b;  write a %= b; instead of a = a % b; 14
  • 15. Special assignment operators  Increment, decrement operators: ++, --  Instead of a = a + 1 you can write a++ or ++a  Instead of a = a - 1 you can write a-- or --a  What is the difference? num = 10; ans = num++; num = 10; ans = ++num; First increment num, then assign num to ans. In the end, num = 11 ans = 11 First assign num to ans, then increment num. In the end, num =11 ans = 10 post-increment pre-increment 15
  • 16. Operator Hierarchy 16 This expression z = a * b + c / d is same as; z = (a * b) + (c / d)
  • 20. Associativity of Operators 20  We can have same priority operators in an expression  Then we check associativity of operators  There are two rules:  Left to Right  means that the operators are performed from left to right  Right to Left  means that the operators are performed from right to left