SlideShare a Scribd company logo
Presentation on:
Array and Do-
While Loop
SUBMITTED BY: Juhi Kumari
ARRAYS
 An array isacontiguouscollection of
storagelocationsthat aredefined by a
singlename.
 Each element of an array hasan unique
number of identification called INDEX
or SUBSCRIPT.
 Making changesto any oneelement of
an array doesnot affect other element of
array.
Types of array
 Single dimensional:
 It has only one subscript.
 They are used to store data
sequentially.
 Only linear data can be presented
in this way.
 Eg: roll no of students.
Declaring Single Dimension
Array
An array is declared using the following syntax:
Dim ArrayName(MaxIndex) as VariableType
Eg: Dim num(5) as integer
OR
Dim ArrayName(LowerBound To UpperBound) as
VariableType
Eg: Dim num(1 to 5) as integer
The LowerBound of the array is the lowest index in
the array, while the UpperBound is the highest index
in the array
Dynamic Arrays
 Dynamic array are those whose size is set
at run time.
 These type of arrays are very flexible
through which we can manage memory
efficiently.
 If some data is no longer needed we can
released the memory occupied by them.
 SYNTEX:
Dim arrayname()
ReDim arrayname()
Example:
Dim num() as integer
Redim num(5)
For k=1 to 5
num(k)=100+k
Next
-Each time redim statement is
executed
all the values stored in array are
lost.
-All the elements values are reset
like fresh array.
-We can use keyword PRESERVE to
resize the array without losing the
existing data.
Syntex:
redim PRESERVE arrayname(index) as integer
example:
redim x(1 to 10) as integer
for j=0 to 10
x(j)= j
print x(j)
next
redim preserve x(1 to 5) as integer
for j=1 to 5
print x(j)
next
Multi dimensional array
(two or three)
 It has two or more subscripts.
 They are easy to manipulate as they
are arranged in rows and columns.
Eg: matrix.
Declaring multidimensional
Array
To define a two-dimensional array or table —
Dim statement specifies number of rows and
columns.
The row is horizontal and the column is vertical.
May specify number of elements initial values
Specify row with first subscript, column with
second subscript, and use a comma to specify the
dimensions.
The Dim Statement for Two-Dimensional
Arrays — General Form
Dim ArrayName(highestRowSubscript,lowestColumnSubscript)
as VariableType
Eg: dim mat(3,3) as integer
for i=1 to 3
for j=0 to 3
mat(I,j)=inputbox(“enter element rowWise”)
next j
next i
Output:
12
(0,0)
10
(0,1)
17
(0,2)
19
(1,0)
11
(1,1)
10
(1,2)
12
(2,0)
6
(2,1)
11
(2,2)
Do......Loop
It executes a blocks of statement as
long as condition is true. Condition is
specified with Do is evaluated. if it is
true then statement are executed
otherwise execution continues from
statement written immediately after
Do.....Loop.
Do While......Loop
 This construct first tests the condition.
 If the condition is true only then control enters
the loop otherwise loop is never executed.
 If the condition is true then statement written
between Do and Loop are executed as long as
condition remains true. when it becomes false
Loop is terminated and execution continues
from statement.
 Syntax:
Do While <condition>
statements
Loop
Program(using do-loop):
Display 1 to 10 number.
I = 1
Do
print I
I = I+1
Loop While (I <= 10)
Program(using do-while):
Display 1 to 10 number.
I = 1
Do While (I <= 10)
print I
I = I+1
Loop
Arrays

More Related Content

PPTX
Structures in c language
PPTX
Arrays in c
PPTX
concept of Array, 1D & 2D array
PPTX
Arrays In C Language
PPTX
Presentation on array
PDF
Data Types and Structures in R
PPTX
Structures in c language
Arrays in c
concept of Array, 1D & 2D array
Arrays In C Language
Presentation on array
Data Types and Structures in R

What's hot (20)

PPTX
Array in c
PDF
R data types
PPTX
Arrays in c language
PPTX
Introduction to Array ppt
PPTX
Basic array in c programming
PDF
3 Data Structure in R
PPTX
Array in C
PPT
Data structure
PPTX
Array in c
PPTX
Stacks, Queues, Binary Search Trees - Lecture 1 - Advanced Data Structures
PPTX
Array 2 hina
PPTX
Arrays in c
PPTX
Array in c programming
PDF
Multiplication of two 3 d sparse matrices using 1d arrays and linked lists
PPTX
Array in C
PPTX
Array in (C) programing
PPTX
Array
PPT
Structured Data Type Arrays
PPT
User defined data type
Array in c
R data types
Arrays in c language
Introduction to Array ppt
Basic array in c programming
3 Data Structure in R
Array in C
Data structure
Array in c
Stacks, Queues, Binary Search Trees - Lecture 1 - Advanced Data Structures
Array 2 hina
Arrays in c
Array in c programming
Multiplication of two 3 d sparse matrices using 1d arrays and linked lists
Array in C
Array in (C) programing
Array
Structured Data Type Arrays
User defined data type
Ad

Similar to Arrays (20)

PPTX
Chapter12
PPTX
Loops and arrays
PPT
September 9 2008
PPTX
Array and functions
PPT
Chapter 08
DOCX
Arrays in VbScript
DOCX
VBScript Functions procedures and arrays.docx
PDF
MA3696 Lecture 6
PDF
procedures and arrays
PPTX
Mod 12
PPT
Lecture 2a arrays
PPTX
A Presentation About Array Manipulation(Insertion & Deletion in an array)
PPT
Lecture7
PPT
Programming Logic and Design: Arrays
PDF
Data structures; arrays By ZAK
PPTX
VB Script
PPTX
Arrays
PPTX
PPT
VB Script Overview
Chapter12
Loops and arrays
September 9 2008
Array and functions
Chapter 08
Arrays in VbScript
VBScript Functions procedures and arrays.docx
MA3696 Lecture 6
procedures and arrays
Mod 12
Lecture 2a arrays
A Presentation About Array Manipulation(Insertion & Deletion in an array)
Lecture7
Programming Logic and Design: Arrays
Data structures; arrays By ZAK
VB Script
Arrays
VB Script Overview
Ad

Recently uploaded (20)

PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Transform Your Business with a Software ERP System
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
Cost to Outsource Software Development in 2025
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
AutoCAD Professional Crack 2025 With License Key
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PDF
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
PDF
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
Nekopoi APK 2025 free lastest update
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
Design an Analysis of Algorithms II-SECS-1021-03
Transform Your Business with a Software ERP System
Why Generative AI is the Future of Content, Code & Creativity?
Cost to Outsource Software Development in 2025
Digital Systems & Binary Numbers (comprehensive )
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Computer Software and OS of computer science of grade 11.pptx
AutoCAD Professional Crack 2025 With License Key
Autodesk AutoCAD Crack Free Download 2025
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
Advanced SystemCare Ultimate Crack + Portable (2025)
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Nekopoi APK 2025 free lastest update
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Design an Analysis of Algorithms I-SECS-1021-03
Operating system designcfffgfgggggggvggggggggg
How to Choose the Right IT Partner for Your Business in Malaysia

Arrays

  • 1. Presentation on: Array and Do- While Loop SUBMITTED BY: Juhi Kumari
  • 2. ARRAYS  An array isacontiguouscollection of storagelocationsthat aredefined by a singlename.  Each element of an array hasan unique number of identification called INDEX or SUBSCRIPT.  Making changesto any oneelement of an array doesnot affect other element of array.
  • 3. Types of array  Single dimensional:  It has only one subscript.  They are used to store data sequentially.  Only linear data can be presented in this way.  Eg: roll no of students.
  • 4. Declaring Single Dimension Array An array is declared using the following syntax: Dim ArrayName(MaxIndex) as VariableType Eg: Dim num(5) as integer OR Dim ArrayName(LowerBound To UpperBound) as VariableType Eg: Dim num(1 to 5) as integer The LowerBound of the array is the lowest index in the array, while the UpperBound is the highest index in the array
  • 5. Dynamic Arrays  Dynamic array are those whose size is set at run time.  These type of arrays are very flexible through which we can manage memory efficiently.  If some data is no longer needed we can released the memory occupied by them.  SYNTEX: Dim arrayname() ReDim arrayname()
  • 6. Example: Dim num() as integer Redim num(5) For k=1 to 5 num(k)=100+k Next
  • 7. -Each time redim statement is executed all the values stored in array are lost. -All the elements values are reset like fresh array. -We can use keyword PRESERVE to resize the array without losing the existing data.
  • 8. Syntex: redim PRESERVE arrayname(index) as integer example: redim x(1 to 10) as integer for j=0 to 10 x(j)= j print x(j) next redim preserve x(1 to 5) as integer for j=1 to 5 print x(j) next
  • 9. Multi dimensional array (two or three)  It has two or more subscripts.  They are easy to manipulate as they are arranged in rows and columns. Eg: matrix.
  • 10. Declaring multidimensional Array To define a two-dimensional array or table — Dim statement specifies number of rows and columns. The row is horizontal and the column is vertical. May specify number of elements initial values Specify row with first subscript, column with second subscript, and use a comma to specify the dimensions.
  • 11. The Dim Statement for Two-Dimensional Arrays — General Form Dim ArrayName(highestRowSubscript,lowestColumnSubscript) as VariableType Eg: dim mat(3,3) as integer for i=1 to 3 for j=0 to 3 mat(I,j)=inputbox(“enter element rowWise”) next j next i
  • 13. Do......Loop It executes a blocks of statement as long as condition is true. Condition is specified with Do is evaluated. if it is true then statement are executed otherwise execution continues from statement written immediately after Do.....Loop.
  • 14. Do While......Loop  This construct first tests the condition.  If the condition is true only then control enters the loop otherwise loop is never executed.  If the condition is true then statement written between Do and Loop are executed as long as condition remains true. when it becomes false Loop is terminated and execution continues from statement.  Syntax: Do While <condition> statements Loop
  • 15. Program(using do-loop): Display 1 to 10 number. I = 1 Do print I I = I+1 Loop While (I <= 10)
  • 16. Program(using do-while): Display 1 to 10 number. I = 1 Do While (I <= 10) print I I = I+1 Loop