SlideShare a Scribd company logo
Introduction ttoo PPrrooggrraammmmiinngg 
LLeeccttuurree ## 4433
Math Library 
 Complex number 
 Matrix 
 Quadratic equation and their solution 
…………….…
DDeessiiggnn RReecciippee 
 TToo ddeessiiggnn aa pprrooggrraamm pprrooppeerrllyy,, wwee mmuusstt :: 
– AAnnaallyyzzee aa pprroobblleemm ssttaatteemmeenntt,, ttyyppiiccaallllyy 
eexxpprreesssseedd aass aa wwoorrdd pprroobblleemm 
– EExxpprreessss iittss eesssseennccee,, aabbssttrraaccttllyy aanndd wwiitthh 
eexxaammpplleess 
– FFoorrmmuullaattee ssttaatteemmeennttss aanndd ccoommmmeennttss iinn aa 
pprreecciissee llaanngguuaaggee ii..ee.. ccooddee 
– EEvvaalluuaattee aanndd rreevviissee tthhee aaccttiivviittiieess iinn lliigghhtt 
ooff cchheecckkss aanndd tteessttss aanndd 
– PPAAYY AATTTTEENNTTIIOONN TTOO DDEETTAAIILL
Matrix 
• Matrix is nothing but a two 
dimensional array of numbers 
• Normally, represented in the 
form of : 
• Rows 
• Columns
Example 
1 2 3 4 
5 6 7 8 
9 10 11 12 
A = 
Three Rows 
Four Columns
i & j are two Integers 
i representing the Row number 
j representing the Column number
Operations Performed with Matrix 
• Addition of two matrices. 
• Addition of a scalar and a matrix 
• Subtraction of two matrices 
• Subtraction of a scalar from a matrix 
• Multiplication of two matrices 
• Multiplication of a scalar with a matrix 
• Division of a scalar with a matrix 
• Transpose of a matrix
Interface
Addition of two Matrices 
Aij+Bij = Cij
Addition of two Matrices 
Size of two matrices must be 
same 
Number of rows and columns 
must be identical for the 
matrices to be addable
Example 
1 2 3 
5 6 7 
9 10 11 
- 
3 6 8 
7 4 7 
9 10 1 
= 
-2 -4 -5 
-2 2 0 
0 0 10 
Cij = Aij - Bij
Adding a Scalar to 
the Matrix 
Ordinary number 
added to every 
element of the 
matrix
Subtracting a Scalar 
from a Matrix 
Ordinary number 
subtracted from 
every element of the 
matrix
Division of Matrix 
by a Scalar 
Divide every element 
of Matrix by a scalar 
number
Example 
Let : 
X be a Scalar number 
A be a Matrix 
C = 
Aij ij 
X
Multiplication of a scalar with a Matrix Example 
Let : 
X is a Scalar number 
A is a Matrix 
X * A 
X * Aij = Cij
Multiply two 
Matrices 
1 2 
* 2 4 
5 6 1 2 
= ( 1 ) ( 2 ) + ( 2 ) ( 1 ) ( 1 ) ( 4 ) + ( 2 ) ( 2 ) 
( 5 ) ( 2 ) + ( 6 ) ( 1 ) ( 5 ) ( 4 ) + ( 6 ) ( 2 )
Rules Regarding 
Matrix Multiplication 
Number of columns of the 1st Matrix 
= 
Number of rows of the 2nd Matrix
Rules rreeggaarrddiinngg MMaattrriixx 
MMuullttiipplliiccaattiioonn 
 FFiirrsstt mmaattrriixx hhaass 
– MM rroowwss 
– NN ccoolluummnnss 
 SSeeccoonndd mmaattrriixx hhaass 
– NN rroowwss 
– PP ccoolluummnnss 
 RReessuullttaanntt mmaattrriixx wwiillll hhaavvee 
– MM rroowwss 
– PP ccoolluummnnss
Transpose of a 
Matrix 
Interchange of rows 
and columns
Transpose of a Matrix 
Example 
1 2 3 
5 6 7 
9 10 11 
1 5 9 
2 6 10 
3 7 11
Transpose of a Non 
Square Matrix 
Size of matrix change after transpose 
A AT 
3 ( Rows ) * 4 ( Columns ) 
Before 
4 ( Rows ) * 3 ( Columns ) 
After
Next Phase of 
Analysis 
• Determine the Constants 
• Memory Allocation 
• What is it’s user interface
Interface
IInntteerrffaaccee 
CCoonnssttrruuccttoorr :: PPaarraammeetteerrss aarree 
NNuummbbeerr ooff rroowwss 
NNuummbbeerr ooff ccoolluummnnss 
DDiissppllaayy ffuunnccttiioonn 
PPlluuss ooppeerraattoorr :: mmeemmbbeerr ooppeerraattoorr ooff tthhee ccllaassss 
SSuubbttrraaccttiioonn ooppeerraattoorr :: mmeemmbbeerr ooppeerraattoorr ooff tthhee 
ccllaassss 
PPlluuss ooppeerraattoorr :: ffrriieenndd ooff tthhee ccllaassss 
SSuubbttrraaccttiioonn ooppeerraattoorr :: ffrriieenndd ooff tthhee ccllaassss
Plus Operator 
A + X 
X + A
Subtraction Operator 
A - X 
X – A
*
IInntteerrffaaccee 
MMuullttiipplliiccaattiioonn OOppeerraattoorr :: MMeemmbbeerr ooff tthhee CCllaassss 
MMuullttiipplliiccaattiioonn OOppeerraattoorr :: FFrriieenndd ooff tthhee CCllaassss 
DDiivviissiioonn OOppeerraattoorr :: MMeemmbbeerr ooff tthhee CCllaassss 
TTrraannssppoossee FFuunnccttiioonn :: MMeemmbbeerr ooff tthhee CCllaassss 
AAssssiiggnnmmeenntt OOppeerraattoorr :: MMeemmbbeerr ooff tthhee CCllaassss 
++== ,, --== :: MMeemmbbeerrss ooff tthhee CCllaassss
Multiplication Operator 
A * X 
X * A
Assignment Operator 
A = B ( Member Operator )
Interface 
>> Extraction Operator : Friend Operator 
<< Stream Insertion Operator : Friend Operator
Copy Constructor
 CCooppyy CCoonnssttrruuccttoorr 
 AAssssiiggnnmmeenntt 
OOppeerraattoorr 
 MMeemmoorryy AAllllooccaattiioonn 
 MMeemmoorryy 
DDeeaallllooccaattiioonn

More Related Content

TXT
Bb2
PDF
3 handouts section3-7
DOC
Dsd previous year university questions
PPTX
Matrices - Discrete Structures
PPTX
An improved to ak max sat (max-sat problem)
PDF
Day 2 repeats.pptx
PDF
Day 1c access, select ordering copy.pptx
Bb2
3 handouts section3-7
Dsd previous year university questions
Matrices - Discrete Structures
An improved to ak max sat (max-sat problem)
Day 2 repeats.pptx
Day 1c access, select ordering copy.pptx

Viewers also liked (20)

PPT
CS201- Introduction to Programming- Lecture 45
PPT
ISL201 - Islamic Studies- Lecture 15
PPT
CS201- Introduction to Programming- Lecture 44
PPT
CS201- Introduction to Programming- Lecture 26
PPT
CS201- Introduction to Programming- Lecture 15
PPS
CS101- Introduction to Computing- Lecture 31
PPT
CS201- Introduction to Programming- Lecture 35
PPT
MGT101 - Financial Accounting- Lecture 36
PPT
MGT101 - Financial Accounting- Lecture 30
PPT
MGT101 - Financial Accounting- Lecture 45
PPS
ENG101- English Comprehension- Lecture 45
PPS
CS101- Introduction to Computing- Lecture 37
PPS
CS101- Introduction to Computing- Lecture 44
PPT
CS201- Introduction to Programming- Lecture 37
PPT
MGT101 - Financial Accounting- Lecture 27
PPS
CS101- Introduction to Computing- Lecture 39
PPS
CS101- Introduction to Computing- Lecture 35
PPS
CS101- Introduction to Computing- Lecture 43
PPT
CS201- Introduction to Programming- Lecture 25
PPT
CS201- Introduction to Programming- Lecture 03
CS201- Introduction to Programming- Lecture 45
ISL201 - Islamic Studies- Lecture 15
CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 26
CS201- Introduction to Programming- Lecture 15
CS101- Introduction to Computing- Lecture 31
CS201- Introduction to Programming- Lecture 35
MGT101 - Financial Accounting- Lecture 36
MGT101 - Financial Accounting- Lecture 30
MGT101 - Financial Accounting- Lecture 45
ENG101- English Comprehension- Lecture 45
CS101- Introduction to Computing- Lecture 37
CS101- Introduction to Computing- Lecture 44
CS201- Introduction to Programming- Lecture 37
MGT101 - Financial Accounting- Lecture 27
CS101- Introduction to Computing- Lecture 39
CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 43
CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 03
Ad

Similar to CS201- Introduction to Programming- Lecture 43 (20)

PPTX
MATRICES.pptx,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
PDF
7.5 Matrices and Matrix Operations
PDF
9.2 Matrices
PPT
Lesson 1 matrix
PDF
R.Ganesh Kumar
PPT
Matrices
PPTX
2 Chapter Two matrix algebra and its application.pptx
PPT
ALLIED MATHEMATICS -I UNIT III MATRICES.ppt
DOC
Lesson 6
PPTX
GATE Preparation : Matrix Algebra
PPT
Section 7.5 version 2 AMhhhhhhhhhhhhhhhhhhhhhhhh.ppt
PPT
Section 7.5 version 2 AMjjjjjjjjjjjjjjjjjjj.ppt
PPT
Matrix Algebra : Mathematics for Business
PPT
Engineering Mathematics in matrices with problems
PPT
Matrix and its applications for the engineering
PPT
Section 7.5 version 2 AM new ppt for every
PPTX
Presentation.pptx
PPTX
matrix algebra
PPT
chap01987654etghujh76687976jgtfhhhgve.ppt
MATRICES.pptx,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
7.5 Matrices and Matrix Operations
9.2 Matrices
Lesson 1 matrix
R.Ganesh Kumar
Matrices
2 Chapter Two matrix algebra and its application.pptx
ALLIED MATHEMATICS -I UNIT III MATRICES.ppt
Lesson 6
GATE Preparation : Matrix Algebra
Section 7.5 version 2 AMhhhhhhhhhhhhhhhhhhhhhhhh.ppt
Section 7.5 version 2 AMjjjjjjjjjjjjjjjjjjj.ppt
Matrix Algebra : Mathematics for Business
Engineering Mathematics in matrices with problems
Matrix and its applications for the engineering
Section 7.5 version 2 AM new ppt for every
Presentation.pptx
matrix algebra
chap01987654etghujh76687976jgtfhhhgve.ppt
Ad

More from Bilal Ahmed (20)

PPT
CS201- Introduction to Programming- Lecture 42
PPT
CS201- Introduction to Programming- Lecture 41
PPT
CS201- Introduction to Programming- Lecture 40
PPT
CS201- Introduction to Programming- Lecture 39
PPT
CS201- Introduction to Programming- Lecture 38
PPT
CS201- Introduction to Programming- Lecture 36
PPT
CS201- Introduction to Programming- Lecture 34
PPT
CS201- Introduction to Programming- Lecture 33
PPT
CS201- Introduction to Programming- Lecture 32
PPT
CS201- Introduction to Programming- Lecture 31
PPT
CS201- Introduction to Programming- Lecture 30
PPT
CS201- Introduction to Programming- Lecture 29
PPT
CS201- Introduction to Programming- Lecture 28
PPT
CS201- Introduction to Programming- Lecture 27
PPT
CS201- Introduction to Programming- Lecture 24
PPT
CS201- Introduction to Programming- Lecture 23
PPT
CS201- Introduction to Programming- Lecture 22
PPT
CS201- Introduction to Programming- Lecture 21
PPT
CS201- Introduction to Programming- Lecture 20
PPT
CS201- Introduction to Programming- Lecture 19
CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 40
CS201- Introduction to Programming- Lecture 39
CS201- Introduction to Programming- Lecture 38
CS201- Introduction to Programming- Lecture 36
CS201- Introduction to Programming- Lecture 34
CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 32
CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 30
CS201- Introduction to Programming- Lecture 29
CS201- Introduction to Programming- Lecture 28
CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 24
CS201- Introduction to Programming- Lecture 23
CS201- Introduction to Programming- Lecture 22
CS201- Introduction to Programming- Lecture 21
CS201- Introduction to Programming- Lecture 20
CS201- Introduction to Programming- Lecture 19

Recently uploaded (20)

PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
01-Introduction-to-Information-Management.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Institutional Correction lecture only . . .
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
GDM (1) (1).pptx small presentation for students
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
VCE English Exam - Section C Student Revision Booklet
Renaissance Architecture: A Journey from Faith to Humanism
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Anesthesia in Laparoscopic Surgery in India
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
01-Introduction-to-Information-Management.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Institutional Correction lecture only . . .
102 student loan defaulters named and shamed – Is someone you know on the list?
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Computing-Curriculum for Schools in Ghana
Final Presentation General Medicine 03-08-2024.pptx
GDM (1) (1).pptx small presentation for students
O5-L3 Freight Transport Ops (International) V1.pdf

CS201- Introduction to Programming- Lecture 43

  • 2. Math Library  Complex number  Matrix  Quadratic equation and their solution …………….…
  • 3. DDeessiiggnn RReecciippee  TToo ddeessiiggnn aa pprrooggrraamm pprrooppeerrllyy,, wwee mmuusstt :: – AAnnaallyyzzee aa pprroobblleemm ssttaatteemmeenntt,, ttyyppiiccaallllyy eexxpprreesssseedd aass aa wwoorrdd pprroobblleemm – EExxpprreessss iittss eesssseennccee,, aabbssttrraaccttllyy aanndd wwiitthh eexxaammpplleess – FFoorrmmuullaattee ssttaatteemmeennttss aanndd ccoommmmeennttss iinn aa pprreecciissee llaanngguuaaggee ii..ee.. ccooddee – EEvvaalluuaattee aanndd rreevviissee tthhee aaccttiivviittiieess iinn lliigghhtt ooff cchheecckkss aanndd tteessttss aanndd – PPAAYY AATTTTEENNTTIIOONN TTOO DDEETTAAIILL
  • 4. Matrix • Matrix is nothing but a two dimensional array of numbers • Normally, represented in the form of : • Rows • Columns
  • 5. Example 1 2 3 4 5 6 7 8 9 10 11 12 A = Three Rows Four Columns
  • 6. i & j are two Integers i representing the Row number j representing the Column number
  • 7. Operations Performed with Matrix • Addition of two matrices. • Addition of a scalar and a matrix • Subtraction of two matrices • Subtraction of a scalar from a matrix • Multiplication of two matrices • Multiplication of a scalar with a matrix • Division of a scalar with a matrix • Transpose of a matrix
  • 9. Addition of two Matrices Aij+Bij = Cij
  • 10. Addition of two Matrices Size of two matrices must be same Number of rows and columns must be identical for the matrices to be addable
  • 11. Example 1 2 3 5 6 7 9 10 11 - 3 6 8 7 4 7 9 10 1 = -2 -4 -5 -2 2 0 0 0 10 Cij = Aij - Bij
  • 12. Adding a Scalar to the Matrix Ordinary number added to every element of the matrix
  • 13. Subtracting a Scalar from a Matrix Ordinary number subtracted from every element of the matrix
  • 14. Division of Matrix by a Scalar Divide every element of Matrix by a scalar number
  • 15. Example Let : X be a Scalar number A be a Matrix C = Aij ij X
  • 16. Multiplication of a scalar with a Matrix Example Let : X is a Scalar number A is a Matrix X * A X * Aij = Cij
  • 17. Multiply two Matrices 1 2 * 2 4 5 6 1 2 = ( 1 ) ( 2 ) + ( 2 ) ( 1 ) ( 1 ) ( 4 ) + ( 2 ) ( 2 ) ( 5 ) ( 2 ) + ( 6 ) ( 1 ) ( 5 ) ( 4 ) + ( 6 ) ( 2 )
  • 18. Rules Regarding Matrix Multiplication Number of columns of the 1st Matrix = Number of rows of the 2nd Matrix
  • 19. Rules rreeggaarrddiinngg MMaattrriixx MMuullttiipplliiccaattiioonn  FFiirrsstt mmaattrriixx hhaass – MM rroowwss – NN ccoolluummnnss  SSeeccoonndd mmaattrriixx hhaass – NN rroowwss – PP ccoolluummnnss  RReessuullttaanntt mmaattrriixx wwiillll hhaavvee – MM rroowwss – PP ccoolluummnnss
  • 20. Transpose of a Matrix Interchange of rows and columns
  • 21. Transpose of a Matrix Example 1 2 3 5 6 7 9 10 11 1 5 9 2 6 10 3 7 11
  • 22. Transpose of a Non Square Matrix Size of matrix change after transpose A AT 3 ( Rows ) * 4 ( Columns ) Before 4 ( Rows ) * 3 ( Columns ) After
  • 23. Next Phase of Analysis • Determine the Constants • Memory Allocation • What is it’s user interface
  • 25. IInntteerrffaaccee CCoonnssttrruuccttoorr :: PPaarraammeetteerrss aarree NNuummbbeerr ooff rroowwss NNuummbbeerr ooff ccoolluummnnss DDiissppllaayy ffuunnccttiioonn PPlluuss ooppeerraattoorr :: mmeemmbbeerr ooppeerraattoorr ooff tthhee ccllaassss SSuubbttrraaccttiioonn ooppeerraattoorr :: mmeemmbbeerr ooppeerraattoorr ooff tthhee ccllaassss PPlluuss ooppeerraattoorr :: ffrriieenndd ooff tthhee ccllaassss SSuubbttrraaccttiioonn ooppeerraattoorr :: ffrriieenndd ooff tthhee ccllaassss
  • 26. Plus Operator A + X X + A
  • 27. Subtraction Operator A - X X – A
  • 28. *
  • 29. IInntteerrffaaccee MMuullttiipplliiccaattiioonn OOppeerraattoorr :: MMeemmbbeerr ooff tthhee CCllaassss MMuullttiipplliiccaattiioonn OOppeerraattoorr :: FFrriieenndd ooff tthhee CCllaassss DDiivviissiioonn OOppeerraattoorr :: MMeemmbbeerr ooff tthhee CCllaassss TTrraannssppoossee FFuunnccttiioonn :: MMeemmbbeerr ooff tthhee CCllaassss AAssssiiggnnmmeenntt OOppeerraattoorr :: MMeemmbbeerr ooff tthhee CCllaassss ++== ,, --== :: MMeemmbbeerrss ooff tthhee CCllaassss
  • 31. Assignment Operator A = B ( Member Operator )
  • 32. Interface >> Extraction Operator : Friend Operator << Stream Insertion Operator : Friend Operator
  • 34.  CCooppyy CCoonnssttrruuccttoorr  AAssssiiggnnmmeenntt OOppeerraattoorr  MMeemmoorryy AAllllooccaattiioonn  MMeemmoorryy DDeeaallllooccaattiioonn