SlideShare a Scribd company logo
1 of 12
An Array as an ADT:
An array is a fixed size sequence of elements of the same type .
An Array is fundamental abstract data type.
Ex:
int A[100]
Here 100 is the fixed size of the array. Specifies the capacity of
the array. And it specifies the elements type like.
Ex:
int A[100]
The basic operation include direct access to each element in the
array by specifying its position so that values can be retrieved
from or stored in that position.
Array have different functionality across various
implementations of programming languages.
• Matrix Addition Algorithm:( A,B,M,N,X,Y)
• A is a Two Dimensional Array with M Rows and N columns
and B is a Two Dimensional Array with X Rows and Y
Columns. This algorithm adds these two arrays
• 1. if (M ≠ X) or (N ≠ Y) Then
• 2. print : Addition is not possible.
3. Exit
[ End of if ]
4.Repeat For I = 1 to M
5. Repeat For J = 1 to N
6. set C [i][j] =A [i][j] + B [i][j]
[End of step 4 for loop]
[End of step 5 for loop]
7. Exit
• Matrix Subtraction Algorithm:( A,B,M,N,X,Y)
• A is a Two Dimensional Array with M Rows and N columns
and B is a Two Dimensional Array with X Rows and Y
Columns. This algorithm subtracts these two arrays.
• 1. if (M ≠ X) or (N ≠ Y) Then
• 2. print : Subtraction is not possible.
3. Exit
[ End of if ]
4.Repeat For I = 1 to M
5. Repeat For J = 1 to N
6. set C [i][j] =A [i][j] - B [i][j]
[End of step 4 for loop]
[End of step 5 for loop]
7. Exit
• Matrix Multiplication Algorithm: ( A,B,M,N,X,Y)
• A is a Two Dimensional Array with M Rows and N columns and B is a
Two Dimensional Array with X Rows and Y Columns. This algorithm
multiplies these two arrays.
• 1. if (M ≠ Y) or (N ≠ X) Then
• 2. print : Multiplication is not possible.
• 3. Else
4.Repeat For I = 1 to N
5. Repeat For J = 1 to X
6. Set c[i] [j] = 0
7. Repeat For K = 1 to Y
8. Set c [i][j] = C [i][j] + A[i][k] * B[k][j]
[ End of step 7 for loop ]
[ End of step 5 for loop ]
[ End of step 4 for loop ]
[End of if ]
9. Exit
Sparse Matrices.
• Matrix with maximum zero entries is termed as sparse
matrix. It can be represented as:
•
• Lower triangular matrix: It has non-zero entries on or
below diagonal.
•
• Upper Triangular matrix: It has non-zero entries on or
above diagonal.
•
• Tri-diagonal matrix: It has non-zero entries on diagonal
and at the places immediately above or below
diagonal.
Control Statements:
• If else
• Nested if else
• If else if
• Loops :
• While loop
• do while loop
• for loop
• In C programs, Statements are executed sequentially in the
order in which they appear in the program.
• But some times we want to use a condition for executing only
a part of program.
• Also many situations arise we want to execute some
statements some statements several times.
If –else:
• This statement is used to test a condition and take one of the
two possible actions.
• If the condition is true then block of statements is executed.
• Otherwise another block of statements is executed.
• Syntax:
• if(condition)
statement1;
else
statement2;
Nested if else:
we can have another if….else statement in the if block or the else
block. This is called nesting of if….else statements.
if(condition)
{
if(condition)
statementA1;
else
statementA2;
}
else
{
if(condition)
statementB1;
else
statementB2;
}
If else if or else if ladder:
• This is a type of nesting in which there is an if …..else statement in every
else part except the last else part.
• Here each condition is checked and when a condition is found to be true,
the statements corresponding to that are executed, and the control comes
out of the nested structure without checking remaining conditions.
• If none of the condition is true then last else part is executed.
• Syntax:
• if (condition)
statement 1;
• else if (condition)
statement 2;
• .
• .
• .
• else
Statement ;
Loops :
Loops are used when we want to execute block of statements several times.
There are 3 loops:
i) while
ii) do while
iii) for
While loop :
This while statements can be written as:
while(condition)
{
Statements; ---- body of the loop
}
It is an entry-controlled loop. If a condition is true then and only then the
body of a loop is executed. After the body of a loop is executed then
control again goes back at the beginning, and the condition is checked if it
is true, the same process is executed until the condition becomes false.
Once the condition becomes false, the control goes out of the loop.
• Do-While Loop
• A do…while loop in C is similar to the while loop except that the condition
is always executed after the body of a loop. It is also called an exit-
controlled loop.
• Syntax of Do-While Loop in C:
do
{
statements ;
} while (expression);
• As we saw in a while loop, the body of the loop is executed only if the
condition is true. In some cases, we have to execute a body of the loop at
least once even if the condition is false. This type of operation can be
achieved by using a do-while loop.
• In the do-while loop, the body of a loop is always executed at least once.
After the body is executed, then it checks the condition. If the condition is
true, then it will again execute the body of a loop otherwise control is
transferred out of the loop.
For loop in C
• A for loop is a more efficient loop structure in ‘C’
programming. The general structure of for loop syntax in C is
as follows:
• Syntax of For Loop in C:
for (initial value; condition; incrementation or decrementation )
{
statements;
}
• The initial value of the for loop is performed only once.
• The condition is a Boolean expression that tests and compares
the counter to a fixed value after each iteration, stopping the
for loop when false is returned.
• The incrementation/decrementation means (increases or
decreases) the counter by a set value.

More Related Content

Similar to matrices_and_loops.pptx

Intro To C++ - Class 09 - Control Statements: Part 1
Intro To C++ - Class 09 - Control Statements: Part 1Intro To C++ - Class 09 - Control Statements: Part 1
Intro To C++ - Class 09 - Control Statements: Part 1Blue Elephant Consulting
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJTANUJ ⠀
 
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHI
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHIBCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHI
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHISowmya Jyothi
 
Unit II chapter 4 Loops in C
Unit II chapter 4 Loops in CUnit II chapter 4 Loops in C
Unit II chapter 4 Loops in CSowmya Jyothi
 
Condition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptxCondition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptxLikhil181
 
c++ Data Types and Selection
c++ Data Types and Selectionc++ Data Types and Selection
c++ Data Types and SelectionAhmed Nobi
 
2. overview of c#
2. overview of c#2. overview of c#
2. overview of c#Rohit Rao
 
C-Programming Control statements.pptx
C-Programming Control statements.pptxC-Programming Control statements.pptx
C-Programming Control statements.pptxSKUP1
 
C-Programming Control statements.pptx
C-Programming Control statements.pptxC-Programming Control statements.pptx
C-Programming Control statements.pptxLECO9
 
lab-8 (1).pptx
lab-8 (1).pptxlab-8 (1).pptx
lab-8 (1).pptxShimoFcis
 
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysUnit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysDevaKumari Vijay
 
Loop and while Loop
Loop and while LoopLoop and while Loop
Loop and while LoopJayBhavsar68
 
C Programming - Decision making, Looping
C  Programming - Decision making, LoopingC  Programming - Decision making, Looping
C Programming - Decision making, LoopingMURALIDHAR R
 

Similar to matrices_and_loops.pptx (20)

Intro To C++ - Class 09 - Control Statements: Part 1
Intro To C++ - Class 09 - Control Statements: Part 1Intro To C++ - Class 09 - Control Statements: Part 1
Intro To C++ - Class 09 - Control Statements: Part 1
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJ
 
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHI
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHIBCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHI
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHI
 
Unit II chapter 4 Loops in C
Unit II chapter 4 Loops in CUnit II chapter 4 Loops in C
Unit II chapter 4 Loops in C
 
Iteration
IterationIteration
Iteration
 
Condition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptxCondition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptx
 
c++ Data Types and Selection
c++ Data Types and Selectionc++ Data Types and Selection
c++ Data Types and Selection
 
2. overview of c#
2. overview of c#2. overview of c#
2. overview of c#
 
C-Programming Control statements.pptx
C-Programming Control statements.pptxC-Programming Control statements.pptx
C-Programming Control statements.pptx
 
C-Programming Control statements.pptx
C-Programming Control statements.pptxC-Programming Control statements.pptx
C-Programming Control statements.pptx
 
lab-8 (1).pptx
lab-8 (1).pptxlab-8 (1).pptx
lab-8 (1).pptx
 
C language (Part 2)
C language (Part 2)C language (Part 2)
C language (Part 2)
 
Java chapter 3
Java chapter 3Java chapter 3
Java chapter 3
 
M C6java6
M C6java6M C6java6
M C6java6
 
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysUnit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
 
Ch6 Loops
Ch6 LoopsCh6 Loops
Ch6 Loops
 
CONTROL STMTS.pptx
CONTROL STMTS.pptxCONTROL STMTS.pptx
CONTROL STMTS.pptx
 
Lecture1.pdf
Lecture1.pdfLecture1.pdf
Lecture1.pdf
 
Loop and while Loop
Loop and while LoopLoop and while Loop
Loop and while Loop
 
C Programming - Decision making, Looping
C  Programming - Decision making, LoopingC  Programming - Decision making, Looping
C Programming - Decision making, Looping
 

More from Koteswari Kasireddy

Chapter-7-Sampling & sampling Distributions.pdf
Chapter-7-Sampling & sampling Distributions.pdfChapter-7-Sampling & sampling Distributions.pdf
Chapter-7-Sampling & sampling Distributions.pdfKoteswari Kasireddy
 
Object_Oriented_Programming_Unit3.pdf
Object_Oriented_Programming_Unit3.pdfObject_Oriented_Programming_Unit3.pdf
Object_Oriented_Programming_Unit3.pdfKoteswari Kasireddy
 
Relational Model and Relational Algebra.pptx
Relational Model and Relational Algebra.pptxRelational Model and Relational Algebra.pptx
Relational Model and Relational Algebra.pptxKoteswari Kasireddy
 
Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptxUnit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptxKoteswari Kasireddy
 
Database System Concepts AND architecture [Autosaved].pptx
Database System Concepts AND architecture [Autosaved].pptxDatabase System Concepts AND architecture [Autosaved].pptx
Database System Concepts AND architecture [Autosaved].pptxKoteswari Kasireddy
 
Control_Statements_in_Python.pptx
Control_Statements_in_Python.pptxControl_Statements_in_Python.pptx
Control_Statements_in_Python.pptxKoteswari Kasireddy
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxparts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxKoteswari Kasireddy
 

More from Koteswari Kasireddy (20)

DA Syllabus outline (2).pptx
DA Syllabus outline (2).pptxDA Syllabus outline (2).pptx
DA Syllabus outline (2).pptx
 
Chapter-7-Sampling & sampling Distributions.pdf
Chapter-7-Sampling & sampling Distributions.pdfChapter-7-Sampling & sampling Distributions.pdf
Chapter-7-Sampling & sampling Distributions.pdf
 
Object_Oriented_Programming_Unit3.pdf
Object_Oriented_Programming_Unit3.pdfObject_Oriented_Programming_Unit3.pdf
Object_Oriented_Programming_Unit3.pdf
 
unit-3_Chapter1_RDRA.pdf
unit-3_Chapter1_RDRA.pdfunit-3_Chapter1_RDRA.pdf
unit-3_Chapter1_RDRA.pdf
 
DBMS_UNIT_1.pdf
DBMS_UNIT_1.pdfDBMS_UNIT_1.pdf
DBMS_UNIT_1.pdf
 
business analytics
business analyticsbusiness analytics
business analytics
 
Relational Model and Relational Algebra.pptx
Relational Model and Relational Algebra.pptxRelational Model and Relational Algebra.pptx
Relational Model and Relational Algebra.pptx
 
CHAPTER -12 it.pptx
CHAPTER -12 it.pptxCHAPTER -12 it.pptx
CHAPTER -12 it.pptx
 
WEB_DATABASE_chapter_4.pptx
WEB_DATABASE_chapter_4.pptxWEB_DATABASE_chapter_4.pptx
WEB_DATABASE_chapter_4.pptx
 
Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptxUnit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
 
Database System Concepts AND architecture [Autosaved].pptx
Database System Concepts AND architecture [Autosaved].pptxDatabase System Concepts AND architecture [Autosaved].pptx
Database System Concepts AND architecture [Autosaved].pptx
 
Evolution Of WEB_students.pptx
Evolution Of WEB_students.pptxEvolution Of WEB_students.pptx
Evolution Of WEB_students.pptx
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
Control_Statements_in_Python.pptx
Control_Statements_in_Python.pptxControl_Statements_in_Python.pptx
Control_Statements_in_Python.pptx
 
Python_Functions_Unit1.pptx
Python_Functions_Unit1.pptxPython_Functions_Unit1.pptx
Python_Functions_Unit1.pptx
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxparts_of_python_programming_language.pptx
parts_of_python_programming_language.pptx
 
linked_list.pptx
linked_list.pptxlinked_list.pptx
linked_list.pptx
 
algorithms_in_linkedlist.pptx
algorithms_in_linkedlist.pptxalgorithms_in_linkedlist.pptx
algorithms_in_linkedlist.pptx
 
Control_Statements.pptx
Control_Statements.pptxControl_Statements.pptx
Control_Statements.pptx
 

Recently uploaded

call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 

Recently uploaded (20)

call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 

matrices_and_loops.pptx

  • 1. An Array as an ADT: An array is a fixed size sequence of elements of the same type . An Array is fundamental abstract data type. Ex: int A[100] Here 100 is the fixed size of the array. Specifies the capacity of the array. And it specifies the elements type like. Ex: int A[100] The basic operation include direct access to each element in the array by specifying its position so that values can be retrieved from or stored in that position. Array have different functionality across various implementations of programming languages.
  • 2. • Matrix Addition Algorithm:( A,B,M,N,X,Y) • A is a Two Dimensional Array with M Rows and N columns and B is a Two Dimensional Array with X Rows and Y Columns. This algorithm adds these two arrays • 1. if (M ≠ X) or (N ≠ Y) Then • 2. print : Addition is not possible. 3. Exit [ End of if ] 4.Repeat For I = 1 to M 5. Repeat For J = 1 to N 6. set C [i][j] =A [i][j] + B [i][j] [End of step 4 for loop] [End of step 5 for loop] 7. Exit
  • 3. • Matrix Subtraction Algorithm:( A,B,M,N,X,Y) • A is a Two Dimensional Array with M Rows and N columns and B is a Two Dimensional Array with X Rows and Y Columns. This algorithm subtracts these two arrays. • 1. if (M ≠ X) or (N ≠ Y) Then • 2. print : Subtraction is not possible. 3. Exit [ End of if ] 4.Repeat For I = 1 to M 5. Repeat For J = 1 to N 6. set C [i][j] =A [i][j] - B [i][j] [End of step 4 for loop] [End of step 5 for loop] 7. Exit
  • 4. • Matrix Multiplication Algorithm: ( A,B,M,N,X,Y) • A is a Two Dimensional Array with M Rows and N columns and B is a Two Dimensional Array with X Rows and Y Columns. This algorithm multiplies these two arrays. • 1. if (M ≠ Y) or (N ≠ X) Then • 2. print : Multiplication is not possible. • 3. Else 4.Repeat For I = 1 to N 5. Repeat For J = 1 to X 6. Set c[i] [j] = 0 7. Repeat For K = 1 to Y 8. Set c [i][j] = C [i][j] + A[i][k] * B[k][j] [ End of step 7 for loop ] [ End of step 5 for loop ] [ End of step 4 for loop ] [End of if ] 9. Exit
  • 5. Sparse Matrices. • Matrix with maximum zero entries is termed as sparse matrix. It can be represented as: • • Lower triangular matrix: It has non-zero entries on or below diagonal. • • Upper Triangular matrix: It has non-zero entries on or above diagonal. • • Tri-diagonal matrix: It has non-zero entries on diagonal and at the places immediately above or below diagonal.
  • 6. Control Statements: • If else • Nested if else • If else if • Loops : • While loop • do while loop • for loop
  • 7. • In C programs, Statements are executed sequentially in the order in which they appear in the program. • But some times we want to use a condition for executing only a part of program. • Also many situations arise we want to execute some statements some statements several times. If –else: • This statement is used to test a condition and take one of the two possible actions. • If the condition is true then block of statements is executed. • Otherwise another block of statements is executed.
  • 8. • Syntax: • if(condition) statement1; else statement2; Nested if else: we can have another if….else statement in the if block or the else block. This is called nesting of if….else statements. if(condition) { if(condition) statementA1; else statementA2; } else { if(condition) statementB1; else statementB2; }
  • 9. If else if or else if ladder: • This is a type of nesting in which there is an if …..else statement in every else part except the last else part. • Here each condition is checked and when a condition is found to be true, the statements corresponding to that are executed, and the control comes out of the nested structure without checking remaining conditions. • If none of the condition is true then last else part is executed. • Syntax: • if (condition) statement 1; • else if (condition) statement 2; • . • . • . • else Statement ;
  • 10. Loops : Loops are used when we want to execute block of statements several times. There are 3 loops: i) while ii) do while iii) for While loop : This while statements can be written as: while(condition) { Statements; ---- body of the loop } It is an entry-controlled loop. If a condition is true then and only then the body of a loop is executed. After the body of a loop is executed then control again goes back at the beginning, and the condition is checked if it is true, the same process is executed until the condition becomes false. Once the condition becomes false, the control goes out of the loop.
  • 11. • Do-While Loop • A do…while loop in C is similar to the while loop except that the condition is always executed after the body of a loop. It is also called an exit- controlled loop. • Syntax of Do-While Loop in C: do { statements ; } while (expression); • As we saw in a while loop, the body of the loop is executed only if the condition is true. In some cases, we have to execute a body of the loop at least once even if the condition is false. This type of operation can be achieved by using a do-while loop. • In the do-while loop, the body of a loop is always executed at least once. After the body is executed, then it checks the condition. If the condition is true, then it will again execute the body of a loop otherwise control is transferred out of the loop.
  • 12. For loop in C • A for loop is a more efficient loop structure in ‘C’ programming. The general structure of for loop syntax in C is as follows: • Syntax of For Loop in C: for (initial value; condition; incrementation or decrementation ) { statements; } • The initial value of the for loop is performed only once. • The condition is a Boolean expression that tests and compares the counter to a fixed value after each iteration, stopping the for loop when false is returned. • The incrementation/decrementation means (increases or decreases) the counter by a set value.