SlideShare une entreprise Scribd logo
1  sur  12
Chapter # 12

     Arrays




  Hamza Mohammad Iqbal
Array
• An array is a set of like variables arranged in
   sequence identified by their subscripts.
                         OR
  An array is a collection of subscripted variables
with the same variable name.
List and tables are called arrays. A list is referred
to as one-dimensional array and a table as two-
dimensional array.

                     Hamza Mohammad Iqbal
Subscripted Variable
• Subscripted variable names are similar to
  simple variable names except that they are
  followed by a subscript.
• Subscript must be either zero or a positive
  integer and must always be enclosed in
  parentheses.
• For example A(2) , B$(4).


                   Hamza Mohammad Iqbal
Storage in subscripted variable
• Each subscripted variable is used to store one
  number or string.
• Values are assigned to the subscripted
  variables by LET, READ or INPUT statements.




                   Hamza Mohammad Iqbal
Filling an array
• Strings or numbers assigned to subscripted
  variables in arrays using LET READ or INPUT
  statement is called filling an array.
• For e.g.
• 10 READ ART$(1),ART$(2)
• 20 DATA PEN,BOOK
• END


                   Hamza Mohammad Iqbal
BIG ARRAYS : DIM
• DIM is a short name used for DIMension.
• It is used to declare an array especially to specify
  more than 10 subscripts.
• DIM statement causes the computer to reserve
  more spaces in its memory required for big
  arrays.
• The number of subscripted variables can be
  increased including the DIM statement in an array
  program.
• Syntax: Line# DIM <VariableName> (subscripted value)

                        Hamza Mohammad Iqbal
Error without using DIM
• When you run a program of an array to store
  more than 10 values. In the output you got
  the error such like BAD subscript error in line#
  because the computer ordinarily reserves
  memory spaces for only 11 elements of an
  array.




                    Hamza Mohammad Iqbal
Two Dimensional Array
• Two dimensional arrays are named the same
  way as one-dimensional arrays.
• Elements in a two-dimensional array are
  commonly referred to as doubly-subscripted
  variables.
• Format: Line# DIM (Array Name) (row,column)



                  Hamza Mohammad Iqbal
Filling two dimensional array
•   One way of filling a two dimensional array is by FOR …. NEXT nested loops.
•   For e.g.
•   10 DIM D(4,3)
•   20 FOR ROW = 1 TO 4
•   30 FOR COL = 1 TO 3
•   40 READ D(ROW,COL)
•   50 NEXT COL
•   60 NEXT ROW
•   70 DATA 3,5,6
•   80 DATA 76,5,3
•   90 DATA 45,4,74
•   100 DATA 34,65,7
•   110 END



                                Hamza Mohammad Iqbal
PRINTING TWO DIMENSIONAL ARRAY
•   10 DIM D(4,3)
•   20 FOR ROW = 1 TO 4
•   30 FOR COL = 1 TO 3
•   40 READ D(ROW,COL)
•   50 NEXT COL
•   60 NEXT ROW
•   70 PRINT “PRINT TWO DIMENSIONAL ARRAY”
•   80 FOR ROW = 1 TO 4
•   90 FOR COL = 1 TO 3
•   100 PRINT D(ROW,COL);
•   110 NEXT COL
•   120 PRINT
•   130 NEXT ROW
•   170 DATA 3,5,6
•   180 DATA 76,5,3
•   190 DATA 45,4,74
•   200 DATA 34,65,7
•   210 END



                                   Hamza Mohammad Iqbal
OUTPUT




Hamza Mohammad Iqbal
Manipulating data with Arrays
• Numerous operations on data can be
  performed using arrays. Such as finding
  particular element in an array, matching
  elements from two arrays and sorting an
  array.
• Important use of arrays is to store data that
  are used later for comparison.


                    Hamza Mohammad Iqbal

Contenu connexe

Tendances

Presentation on array
Presentation on array Presentation on array
Presentation on array
topu93
 

Tendances (20)

Arrays in c language
Arrays in c languageArrays in c language
Arrays in c language
 
Data Analysis with Python Pandas
Data Analysis with Python PandasData Analysis with Python Pandas
Data Analysis with Python Pandas
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Mesics lecture 8 arrays in 'c'
Mesics lecture 8   arrays in 'c'Mesics lecture 8   arrays in 'c'
Mesics lecture 8 arrays in 'c'
 
Presentation on array
Presentation on array Presentation on array
Presentation on array
 
Python and CSV Connectivity
Python and CSV ConnectivityPython and CSV Connectivity
Python and CSV Connectivity
 
Array in c
Array in cArray in c
Array in c
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
 
Arrays in C++
Arrays in C++Arrays in C++
Arrays in C++
 
Moving Data to and From R
Moving Data to and From RMoving Data to and From R
Moving Data to and From R
 
Basic array in c programming
Basic array in c programmingBasic array in c programming
Basic array in c programming
 
Arrays
ArraysArrays
Arrays
 
Arrays Basics
Arrays BasicsArrays Basics
Arrays Basics
 
Arrays
ArraysArrays
Arrays
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
 
Array C programming
Array C programmingArray C programming
Array C programming
 
Array in c++
Array in c++Array in c++
Array in c++
 
BAS 150 Lesson 4 Lecture
BAS 150 Lesson 4 LectureBAS 150 Lesson 4 Lecture
BAS 150 Lesson 4 Lecture
 
Arrays In C
Arrays In CArrays In C
Arrays In C
 

En vedette (16)

Aula de 17 02-2013
Aula de 17 02-2013Aula de 17 02-2013
Aula de 17 02-2013
 
Que me molesta
Que me molestaQue me molesta
Que me molesta
 
Presentation1
Presentation1Presentation1
Presentation1
 
Filo 02 26tptptptp
Filo 02 26tptptptpFilo 02 26tptptptp
Filo 02 26tptptptp
 
Trungthuc
TrungthucTrungthuc
Trungthuc
 
Bridge presentation
Bridge presentationBridge presentation
Bridge presentation
 
inSis Infoview
inSis InfoviewinSis Infoview
inSis Infoview
 
Indicadores 3 periodo
Indicadores 3 periodoIndicadores 3 periodo
Indicadores 3 periodo
 
inSis Oneview
inSis OneviewinSis Oneview
inSis Oneview
 
cisco case solve
cisco case solvecisco case solve
cisco case solve
 
Unip universidade paulista disciplina-online - sistemas de conteúdo onlin...
Unip   universidade paulista   disciplina-online - sistemas de conteúdo onlin...Unip   universidade paulista   disciplina-online - sistemas de conteúdo onlin...
Unip universidade paulista disciplina-online - sistemas de conteúdo onlin...
 
Assign 20 synergy worksheet
Assign 20 synergy worksheetAssign 20 synergy worksheet
Assign 20 synergy worksheet
 
éTica
éTicaéTica
éTica
 
Modelo de divulgação do projeto social
Modelo de divulgação do projeto socialModelo de divulgação do projeto social
Modelo de divulgação do projeto social
 
Contemplating the Beauty of Crimea...
Contemplating the Beauty of Crimea...Contemplating the Beauty of Crimea...
Contemplating the Beauty of Crimea...
 
Neurotransmitters and its mechanism of action
Neurotransmitters and its mechanism of actionNeurotransmitters and its mechanism of action
Neurotransmitters and its mechanism of action
 

Similaire à Chapter12

Programming fundamentals week 12.pptx
Programming fundamentals week 12.pptxProgramming fundamentals week 12.pptx
Programming fundamentals week 12.pptx
dfsdg3
 

Similaire à Chapter12 (20)

Unit 6. Arrays
Unit 6. ArraysUnit 6. Arrays
Unit 6. Arrays
 
Basics of Python
Basics of PythonBasics of Python
Basics of Python
 
C-Programming Arrays.pptx
C-Programming  Arrays.pptxC-Programming  Arrays.pptx
C-Programming Arrays.pptx
 
C-Programming Arrays.pptx
C-Programming  Arrays.pptxC-Programming  Arrays.pptx
C-Programming Arrays.pptx
 
Arrays.pptx
Arrays.pptxArrays.pptx
Arrays.pptx
 
Matlab Tutorial for Beginners - I
Matlab Tutorial for Beginners - IMatlab Tutorial for Beginners - I
Matlab Tutorial for Beginners - I
 
Lisp and scheme i
Lisp and scheme iLisp and scheme i
Lisp and scheme i
 
Programming fundamentals week 12.pptx
Programming fundamentals week 12.pptxProgramming fundamentals week 12.pptx
Programming fundamentals week 12.pptx
 
Practical 03 (1).pptx
Practical 03 (1).pptxPractical 03 (1).pptx
Practical 03 (1).pptx
 
DataStructures.pptx
DataStructures.pptxDataStructures.pptx
DataStructures.pptx
 
Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions
 
Dbms sql-final
Dbms  sql-finalDbms  sql-final
Dbms sql-final
 
Arrays and addressing modes
Arrays and addressing modesArrays and addressing modes
Arrays and addressing modes
 
Array
ArrayArray
Array
 
Radix sort
Radix sortRadix sort
Radix sort
 
Regular expression for everyone
Regular expression for everyoneRegular expression for everyone
Regular expression for everyone
 
Basics of array.pptx
Basics of array.pptxBasics of array.pptx
Basics of array.pptx
 
Arrays_and_Strings_in_C_Programming.pptx
Arrays_and_Strings_in_C_Programming.pptxArrays_and_Strings_in_C_Programming.pptx
Arrays_and_Strings_in_C_Programming.pptx
 
PHP array 1
PHP array 1PHP array 1
PHP array 1
 
File Structure Concepts
File Structure ConceptsFile Structure Concepts
File Structure Concepts
 

Dernier

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Dernier (20)

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 

Chapter12

  • 1. Chapter # 12 Arrays Hamza Mohammad Iqbal
  • 2. Array • An array is a set of like variables arranged in sequence identified by their subscripts. OR An array is a collection of subscripted variables with the same variable name. List and tables are called arrays. A list is referred to as one-dimensional array and a table as two- dimensional array. Hamza Mohammad Iqbal
  • 3. Subscripted Variable • Subscripted variable names are similar to simple variable names except that they are followed by a subscript. • Subscript must be either zero or a positive integer and must always be enclosed in parentheses. • For example A(2) , B$(4). Hamza Mohammad Iqbal
  • 4. Storage in subscripted variable • Each subscripted variable is used to store one number or string. • Values are assigned to the subscripted variables by LET, READ or INPUT statements. Hamza Mohammad Iqbal
  • 5. Filling an array • Strings or numbers assigned to subscripted variables in arrays using LET READ or INPUT statement is called filling an array. • For e.g. • 10 READ ART$(1),ART$(2) • 20 DATA PEN,BOOK • END Hamza Mohammad Iqbal
  • 6. BIG ARRAYS : DIM • DIM is a short name used for DIMension. • It is used to declare an array especially to specify more than 10 subscripts. • DIM statement causes the computer to reserve more spaces in its memory required for big arrays. • The number of subscripted variables can be increased including the DIM statement in an array program. • Syntax: Line# DIM <VariableName> (subscripted value) Hamza Mohammad Iqbal
  • 7. Error without using DIM • When you run a program of an array to store more than 10 values. In the output you got the error such like BAD subscript error in line# because the computer ordinarily reserves memory spaces for only 11 elements of an array. Hamza Mohammad Iqbal
  • 8. Two Dimensional Array • Two dimensional arrays are named the same way as one-dimensional arrays. • Elements in a two-dimensional array are commonly referred to as doubly-subscripted variables. • Format: Line# DIM (Array Name) (row,column) Hamza Mohammad Iqbal
  • 9. Filling two dimensional array • One way of filling a two dimensional array is by FOR …. NEXT nested loops. • For e.g. • 10 DIM D(4,3) • 20 FOR ROW = 1 TO 4 • 30 FOR COL = 1 TO 3 • 40 READ D(ROW,COL) • 50 NEXT COL • 60 NEXT ROW • 70 DATA 3,5,6 • 80 DATA 76,5,3 • 90 DATA 45,4,74 • 100 DATA 34,65,7 • 110 END Hamza Mohammad Iqbal
  • 10. PRINTING TWO DIMENSIONAL ARRAY • 10 DIM D(4,3) • 20 FOR ROW = 1 TO 4 • 30 FOR COL = 1 TO 3 • 40 READ D(ROW,COL) • 50 NEXT COL • 60 NEXT ROW • 70 PRINT “PRINT TWO DIMENSIONAL ARRAY” • 80 FOR ROW = 1 TO 4 • 90 FOR COL = 1 TO 3 • 100 PRINT D(ROW,COL); • 110 NEXT COL • 120 PRINT • 130 NEXT ROW • 170 DATA 3,5,6 • 180 DATA 76,5,3 • 190 DATA 45,4,74 • 200 DATA 34,65,7 • 210 END Hamza Mohammad Iqbal
  • 12. Manipulating data with Arrays • Numerous operations on data can be performed using arrays. Such as finding particular element in an array, matching elements from two arrays and sorting an array. • Important use of arrays is to store data that are used later for comparison. Hamza Mohammad Iqbal