SlideShare a Scribd company logo
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 1
Blue Elephant Consulting
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJ
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
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
Sowmya Jyothi
 
Iteration
IterationIteration
Iteration
Liam Dunphy
 
06-Control-Statementskkkkkkkkkkkkkk.pptx
06-Control-Statementskkkkkkkkkkkkkk.pptx06-Control-Statementskkkkkkkkkkkkkk.pptx
06-Control-Statementskkkkkkkkkkkkkk.pptx
kamalsmail1
 
Condition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptxCondition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptx
Likhil181
 
c++ Data Types and Selection
c++ Data Types and Selectionc++ Data Types and Selection
c++ Data Types and Selection
Ahmed 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.pptx
SKUP1
 
C-Programming Control statements.pptx
C-Programming Control statements.pptxC-Programming Control statements.pptx
C-Programming Control statements.pptx
LECO9
 
lab-8 (1).pptx
lab-8 (1).pptxlab-8 (1).pptx
lab-8 (1).pptx
ShimoFcis
 
C language (Part 2)
C language (Part 2)C language (Part 2)
C language (Part 2)
SURBHI SAROHA
 
classVIII_Coding_Teacher_Presentation.pptx
classVIII_Coding_Teacher_Presentation.pptxclassVIII_Coding_Teacher_Presentation.pptx
classVIII_Coding_Teacher_Presentation.pptx
bhanutickets
 
Java chapter 3
Java chapter 3Java chapter 3
Java chapter 3
Abdii Rashid
 
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
DevaKumari Vijay
 
Ch6 Loops
Ch6 LoopsCh6 Loops
Ch6 Loops
SzeChingChen
 
CONTROL STMTS.pptx
CONTROL STMTS.pptxCONTROL STMTS.pptx
CONTROL STMTS.pptx
JavvajiVenkat
 
Lecture1.pdf
Lecture1.pdfLecture1.pdf
Lecture1.pdf
SakhilejasonMsibi
 

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
 
06-Control-Statementskkkkkkkkkkkkkk.pptx
06-Control-Statementskkkkkkkkkkkkkk.pptx06-Control-Statementskkkkkkkkkkkkkk.pptx
06-Control-Statementskkkkkkkkkkkkkk.pptx
 
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)
 
classVIII_Coding_Teacher_Presentation.pptx
classVIII_Coding_Teacher_Presentation.pptxclassVIII_Coding_Teacher_Presentation.pptx
classVIII_Coding_Teacher_Presentation.pptx
 
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
 

More from Koteswari Kasireddy

DA Syllabus outline (2).pptx
DA Syllabus outline (2).pptxDA Syllabus outline (2).pptx
DA Syllabus outline (2).pptx
Koteswari Kasireddy
 
Chapter-7-Sampling & sampling Distributions.pdf
Chapter-7-Sampling & sampling Distributions.pdfChapter-7-Sampling & sampling Distributions.pdf
Chapter-7-Sampling & sampling Distributions.pdf
Koteswari Kasireddy
 
Object_Oriented_Programming_Unit3.pdf
Object_Oriented_Programming_Unit3.pdfObject_Oriented_Programming_Unit3.pdf
Object_Oriented_Programming_Unit3.pdf
Koteswari Kasireddy
 
unit-3_Chapter1_RDRA.pdf
unit-3_Chapter1_RDRA.pdfunit-3_Chapter1_RDRA.pdf
unit-3_Chapter1_RDRA.pdf
Koteswari Kasireddy
 
DBMS_UNIT_1.pdf
DBMS_UNIT_1.pdfDBMS_UNIT_1.pdf
DBMS_UNIT_1.pdf
Koteswari Kasireddy
 
Relational Model and Relational Algebra.pptx
Relational Model and Relational Algebra.pptxRelational Model and Relational Algebra.pptx
Relational Model and Relational Algebra.pptx
Koteswari Kasireddy
 
WEB_DATABASE_chapter_4.pptx
WEB_DATABASE_chapter_4.pptxWEB_DATABASE_chapter_4.pptx
WEB_DATABASE_chapter_4.pptx
Koteswari 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).pptx
Koteswari 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].pptx
Koteswari Kasireddy
 
Evolution Of WEB_students.pptx
Evolution Of WEB_students.pptxEvolution Of WEB_students.pptx
Evolution Of WEB_students.pptx
Koteswari Kasireddy
 
Control_Statements_in_Python.pptx
Control_Statements_in_Python.pptxControl_Statements_in_Python.pptx
Control_Statements_in_Python.pptx
Koteswari Kasireddy
 
Python_Functions_Unit1.pptx
Python_Functions_Unit1.pptxPython_Functions_Unit1.pptx
Python_Functions_Unit1.pptx
Koteswari Kasireddy
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxparts_of_python_programming_language.pptx
parts_of_python_programming_language.pptx
Koteswari Kasireddy
 
linked_list.pptx
linked_list.pptxlinked_list.pptx
linked_list.pptx
Koteswari Kasireddy
 
algorithms_in_linkedlist.pptx
algorithms_in_linkedlist.pptxalgorithms_in_linkedlist.pptx
algorithms_in_linkedlist.pptx
Koteswari Kasireddy
 
Control_Statements.pptx
Control_Statements.pptxControl_Statements.pptx
Control_Statements.pptx
Koteswari 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

Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 

Recently uploaded (20)

Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 

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.