SlideShare a Scribd company logo
1 of 12
Microsoft® Small Basic Stacks and Arrays Estimated time to complete this lesson: 1 hour
Stacks and Arrays In this lesson, you will learn about: Using different operations of the Stack object. Using different operations of the Array object.
Stacks and Arrays Before we move on to discuss the Array object and the Stack object, let’s first understand when we use both of these objects. Arrays can be multi-dimensional, but a stack is only one-dimensional. You can use arrays  to directly access any of its elements but if you use a stack, you can access only the top element. For instance, if you want to access the last element of the stack, you must go through all the elements from the beginning.
The Array Object So far, you have learned about variables that store single values. Now, let’s learn about a special variable called an Array.  An array is a type of variable that can store multiple values at a time. If you want to store the names of five users, then instead of creating different variables, you can just use one variable to store all of the five names.  You use the indexing method to store multiple values in an array. For example, you can create an array called name as:  name[1], name[2], name[3], name[4], and name[5]. Here, 1, 2, 3, 4, and 5 are the indices for the name array. The name[1], name[2]… may seem to you as different variables, but they are all just one variable!
Operations of the Array Object You can use the IsArray operation to check whether the specified variable is an array. You can use the ContainsIndex operation to check whether the array contains the specified index. This operation is helpful when you want to check whether the array’s index is initialized by a specific value. You can use the ContainsValue operation to check whether the array contains the specified value. You can use this operation to check if the array’s value was stored in the specified index. Now, let’s discuss some operations of the Array object, such as  IsArray, ContainsIndex, and ContainsValue.
Operations of the Array Object As you can see, Subjects as an array stores the names of five different subjects. You can use the IsArray operation to check if Subjects is an array. You can also use the ContainsIndex operation to check the availability of the index Subjects[4] in the Subjects array. Lastly, you can use the ContainsValue operation to see if the value “Math” is available in the Subjects array. Let’s see how we can use these operations in a program. output
Operations of the Array Object Look at this example to learn how to use these operations. In this example, because you don’t know the indices for the Employee array, you use the GetAllIndices operation. Next, you use the GetItemCount operation in a For loop to list the information stored in the Employee array. The Array object also provides more useful operations, such as:  ,[object Object]
GetItemCount,[object Object]
 Operations of the Stack Object The Stack object stores data just as a stack of plates. Let’s take a look at some examples to understand how it works. The PushValue operation is like adding a new plate to the top of the stack of plates. With the help of this operation, you can push a value to the specified stack. The PopValue operation is like picking out a plate from the top of the stack. You can use this operation to pop out a value from the specified stack. The GetCount operation provides the total number of plates in the stack. You can use this operation to determine the count of items in a specified stack.
Operations of  the Stack Object In this example, you use the PushValue operation to push 50 plates into an empty container. Then by using the PopValue operation, you take eight plates away from the stack. Now, use the GetCount operation to get the total number of plates in the container. You also display the value of the plate, which is placed at the top. Let’s write a program to better understand these operations.
Let’s Summarize… Congratulations! Now you know how to: Use different operations of the Stack object. Use different operations of the Array object.
It’s Time to Apply Your Learning… Using the Array object, write a program for “Flight Reservation” that allows you to perform the following actions: ,[object Object]

More Related Content

What's hot

Data structures and algorithms lab9
Data structures and algorithms lab9Data structures and algorithms lab9
Data structures and algorithms lab9
Bianca Teşilă
 

What's hot (20)

Data structures and algorithms lab9
Data structures and algorithms lab9Data structures and algorithms lab9
Data structures and algorithms lab9
 
Essential NumPy
Essential NumPyEssential NumPy
Essential NumPy
 
Cosc 2425 project 2 part 1 implement the following c++ code
Cosc 2425   project 2 part 1 implement the following c++ code Cosc 2425   project 2 part 1 implement the following c++ code
Cosc 2425 project 2 part 1 implement the following c++ code
 
Ppt lesson 11
Ppt lesson 11Ppt lesson 11
Ppt lesson 11
 
6nullables in c#
6nullables in c#6nullables in c#
6nullables in c#
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Stack application
Stack applicationStack application
Stack application
 
Queue
QueueQueue
Queue
 
Data Structure (Stack)
Data Structure (Stack)Data Structure (Stack)
Data Structure (Stack)
 
Assignment in java
Assignment in javaAssignment in java
Assignment in java
 
Data Analysis packages
Data Analysis packagesData Analysis packages
Data Analysis packages
 
Algorithm and Data Structure - Queue
Algorithm and Data Structure - QueueAlgorithm and Data Structure - Queue
Algorithm and Data Structure - Queue
 
Algorithm and Data Structure - Stack
Algorithm and Data Structure - StackAlgorithm and Data Structure - Stack
Algorithm and Data Structure - Stack
 
Tech Talk - JPA and Query Optimization - publish
Tech Talk  -  JPA and Query Optimization - publishTech Talk  -  JPA and Query Optimization - publish
Tech Talk - JPA and Query Optimization - publish
 
Java Arrays and DateTime Functions
Java Arrays and DateTime FunctionsJava Arrays and DateTime Functions
Java Arrays and DateTime Functions
 
C programming exercises and solutions
C programming exercises and solutions C programming exercises and solutions
C programming exercises and solutions
 
Priority Queue
Priority QueuePriority Queue
Priority Queue
 
Stack Data Structure
Stack Data StructureStack Data Structure
Stack Data Structure
 
Function BPK2
Function BPK2Function BPK2
Function BPK2
 
Ecet 370 week 2 lab 2
Ecet 370 week 2 lab 2Ecet 370 week 2 lab 2
Ecet 370 week 2 lab 2
 

Viewers also liked (6)

4.2 responding to events
4.2   responding to events4.2   responding to events
4.2 responding to events
 
3.6 debugging aids
3.6   debugging aids3.6   debugging aids
3.6 debugging aids
 
4.1 playing with shapes
4.1   playing with shapes4.1   playing with shapes
4.1 playing with shapes
 
4.4 advanced games
4.4   advanced games4.4   advanced games
4.4 advanced games
 
5.1 sharing code
5.1   sharing code5.1   sharing code
5.1 sharing code
 
Mlp_winter-2015
Mlp_winter-2015Mlp_winter-2015
Mlp_winter-2015
 

Similar to 3.2 stacks and arrays

Introduction and BackgroundIn recent lectures we discussed usi.pdf
Introduction and BackgroundIn recent lectures we discussed usi.pdfIntroduction and BackgroundIn recent lectures we discussed usi.pdf
Introduction and BackgroundIn recent lectures we discussed usi.pdf
arpitaeron555
 
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfGetting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
info309708
 
java I am trying to run my code but it is not letting me .pdf
java    I am trying to run my code but it is not letting me .pdfjava    I am trying to run my code but it is not letting me .pdf
java I am trying to run my code but it is not letting me .pdf
adinathassociates
 

Similar to 3.2 stacks and arrays (20)

LectureNotes-06-DSA
LectureNotes-06-DSALectureNotes-06-DSA
LectureNotes-06-DSA
 
Lecture 7- Iterator and for loop over arrays
Lecture 7- Iterator and for loop over arraysLecture 7- Iterator and for loop over arrays
Lecture 7- Iterator and for loop over arrays
 
Arrays in programming
Arrays in programmingArrays in programming
Arrays in programming
 
Java Unit 2 (Part 2)
Java Unit 2 (Part 2)Java Unit 2 (Part 2)
Java Unit 2 (Part 2)
 
01-intro_stacks.ppt
01-intro_stacks.ppt01-intro_stacks.ppt
01-intro_stacks.ppt
 
Any Which Array But Loose
Any Which Array But LooseAny Which Array But Loose
Any Which Array But Loose
 
Lesson 11 one dimensional array
Lesson 11 one dimensional arrayLesson 11 one dimensional array
Lesson 11 one dimensional array
 
Introduction and BackgroundIn recent lectures we discussed usi.pdf
Introduction and BackgroundIn recent lectures we discussed usi.pdfIntroduction and BackgroundIn recent lectures we discussed usi.pdf
Introduction and BackgroundIn recent lectures we discussed usi.pdf
 
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfGetting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
 
java I am trying to run my code but it is not letting me .pdf
java    I am trying to run my code but it is not letting me .pdfjava    I am trying to run my code but it is not letting me .pdf
java I am trying to run my code but it is not letting me .pdf
 
Java collections notes
Java collections notesJava collections notes
Java collections notes
 
Data structures in c#
Data structures in c#Data structures in c#
Data structures in c#
 
Data Structure In C#
Data Structure In C#Data Structure In C#
Data Structure In C#
 
Advanced core java
Advanced core javaAdvanced core java
Advanced core java
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Mod 12
Mod 12Mod 12
Mod 12
 
unit 2.pptx
unit 2.pptxunit 2.pptx
unit 2.pptx
 
Arrays Introduction.pptx
Arrays Introduction.pptxArrays Introduction.pptx
Arrays Introduction.pptx
 
Lecture 4 - Object Interaction and Collections
Lecture 4 - Object Interaction and CollectionsLecture 4 - Object Interaction and Collections
Lecture 4 - Object Interaction and Collections
 
STACK.pptx
STACK.pptxSTACK.pptx
STACK.pptx
 

More from allenbailey

4.3 collision detection
4.3   collision detection4.3   collision detection
4.3 collision detection
allenbailey
 
3.5 the controls object
3.5   the controls object3.5   the controls object
3.5 the controls object
allenbailey
 
3.4 events and interactivity
3.4   events and interactivity3.4   events and interactivity
3.4 events and interactivity
allenbailey
 
3.1 file input and output
3.1   file input and output3.1   file input and output
3.1 file input and output
allenbailey
 
2.6 flickr, image list, and network objects
2.6   flickr, image list, and network objects2.6   flickr, image list, and network objects
2.6 flickr, image list, and network objects
allenbailey
 
2.5 clock, desktop, and dictionary objects
2.5   clock, desktop, and dictionary objects2.5   clock, desktop, and dictionary objects
2.5 clock, desktop, and dictionary objects
allenbailey
 
2.4 sound, program, and text objects
2.4   sound, program, and text objects2.4   sound, program, and text objects
2.4 sound, program, and text objects
allenbailey
 
2.3 exploring shapes
2.3   exploring shapes2.3   exploring shapes
2.3 exploring shapes
allenbailey
 
2.2 turtle graphics
2.2   turtle graphics2.2   turtle graphics
2.2 turtle graphics
allenbailey
 
2.1 graphics window
2.1   graphics window2.1   graphics window
2.1 graphics window
allenbailey
 
1.5 branching and subroutines
1.5   branching and subroutines1.5   branching and subroutines
1.5 branching and subroutines
allenbailey
 
1.4 conditions and loops
1.4   conditions and loops1.4   conditions and loops
1.4 conditions and loops
allenbailey
 
1.2 statements, properties, and operations
1.2   statements, properties, and operations1.2   statements, properties, and operations
1.2 statements, properties, and operations
allenbailey
 
1.1 introduction to small basic
1.1   introduction to small basic1.1   introduction to small basic
1.1 introduction to small basic
allenbailey
 

More from allenbailey (15)

4.3 collision detection
4.3   collision detection4.3   collision detection
4.3 collision detection
 
3.5 the controls object
3.5   the controls object3.5   the controls object
3.5 the controls object
 
3.4 events and interactivity
3.4   events and interactivity3.4   events and interactivity
3.4 events and interactivity
 
3.1 file input and output
3.1   file input and output3.1   file input and output
3.1 file input and output
 
2.6 flickr, image list, and network objects
2.6   flickr, image list, and network objects2.6   flickr, image list, and network objects
2.6 flickr, image list, and network objects
 
2.5 clock, desktop, and dictionary objects
2.5   clock, desktop, and dictionary objects2.5   clock, desktop, and dictionary objects
2.5 clock, desktop, and dictionary objects
 
2.4 sound, program, and text objects
2.4   sound, program, and text objects2.4   sound, program, and text objects
2.4 sound, program, and text objects
 
2.3 exploring shapes
2.3   exploring shapes2.3   exploring shapes
2.3 exploring shapes
 
2.2 turtle graphics
2.2   turtle graphics2.2   turtle graphics
2.2 turtle graphics
 
2.1 graphics window
2.1   graphics window2.1   graphics window
2.1 graphics window
 
1.5 branching and subroutines
1.5   branching and subroutines1.5   branching and subroutines
1.5 branching and subroutines
 
1.4 conditions and loops
1.4   conditions and loops1.4   conditions and loops
1.4 conditions and loops
 
1.3 variables
1.3   variables1.3   variables
1.3 variables
 
1.2 statements, properties, and operations
1.2   statements, properties, and operations1.2   statements, properties, and operations
1.2 statements, properties, and operations
 
1.1 introduction to small basic
1.1   introduction to small basic1.1   introduction to small basic
1.1 introduction to small basic
 

Recently uploaded

Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171
Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171
Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171
Delhi Call Girls 📞9899900591 ✔️ High Profile Service 100% Safe
 
Karnal Call Girls 8860008073 Dyal Singh Colony Call Girls Service in Karnal E...
Karnal Call Girls 8860008073 Dyal Singh Colony Call Girls Service in Karnal E...Karnal Call Girls 8860008073 Dyal Singh Colony Call Girls Service in Karnal E...
Karnal Call Girls 8860008073 Dyal Singh Colony Call Girls Service in Karnal E...
Apsara Of India
 
Call Girls Agency In Goa 💚 9316020077 💚 Call Girl Goa By Russian Call Girl ...
Call Girls  Agency In Goa  💚 9316020077 💚 Call Girl Goa By Russian Call Girl ...Call Girls  Agency In Goa  💚 9316020077 💚 Call Girl Goa By Russian Call Girl ...
Call Girls Agency In Goa 💚 9316020077 💚 Call Girl Goa By Russian Call Girl ...
russian goa call girl and escorts service
 
Russian ℂall gIRLS In Goa 9316020077 ℂall gIRLS Service In Goa
Russian ℂall gIRLS In Goa 9316020077  ℂall gIRLS Service  In GoaRussian ℂall gIRLS In Goa 9316020077  ℂall gIRLS Service  In Goa
Russian ℂall gIRLS In Goa 9316020077 ℂall gIRLS Service In Goa
russian goa call girl and escorts service
 
Goa Call "Girls Service 9316020077 Call "Girls in Goa
Goa Call "Girls  Service   9316020077 Call "Girls in GoaGoa Call "Girls  Service   9316020077 Call "Girls in Goa
Goa Call "Girls Service 9316020077 Call "Girls in Goa
sexy call girls service in goa
 
CHEAP Call Girls in Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in  Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in  Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...
Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...
Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...
 
Model Call Girls In Velappanchavadi WhatsApp Booking 7427069034 call girl ser...
Model Call Girls In Velappanchavadi WhatsApp Booking 7427069034 call girl ser...Model Call Girls In Velappanchavadi WhatsApp Booking 7427069034 call girl ser...
Model Call Girls In Velappanchavadi WhatsApp Booking 7427069034 call girl ser...
 
Call Girls Nashik Gayatri 7001305949 Independent Escort Service Nashik
Call Girls Nashik Gayatri 7001305949 Independent Escort Service NashikCall Girls Nashik Gayatri 7001305949 Independent Escort Service Nashik
Call Girls Nashik Gayatri 7001305949 Independent Escort Service Nashik
 
Book Paid Sonagachi Call Girls Kolkata 𖠋 8250192130 𖠋Low Budget Full Independ...
Book Paid Sonagachi Call Girls Kolkata 𖠋 8250192130 𖠋Low Budget Full Independ...Book Paid Sonagachi Call Girls Kolkata 𖠋 8250192130 𖠋Low Budget Full Independ...
Book Paid Sonagachi Call Girls Kolkata 𖠋 8250192130 𖠋Low Budget Full Independ...
 
Call Girl Nashik Amaira 7001305949 Independent Escort Service Nashik
Call Girl Nashik Amaira 7001305949 Independent Escort Service NashikCall Girl Nashik Amaira 7001305949 Independent Escort Service Nashik
Call Girl Nashik Amaira 7001305949 Independent Escort Service Nashik
 
Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171
Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171
Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171
 
Karnal Call Girls 8860008073 Dyal Singh Colony Call Girls Service in Karnal E...
Karnal Call Girls 8860008073 Dyal Singh Colony Call Girls Service in Karnal E...Karnal Call Girls 8860008073 Dyal Singh Colony Call Girls Service in Karnal E...
Karnal Call Girls 8860008073 Dyal Singh Colony Call Girls Service in Karnal E...
 
↑Top Model (Kolkata) Call Girls Rajpur ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Rajpur ⟟ 8250192130 ⟟ High Class Call Girl In...↑Top Model (Kolkata) Call Girls Rajpur ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Rajpur ⟟ 8250192130 ⟟ High Class Call Girl In...
 
Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata ✔ 62971...
Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata ✔ 62971...Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata ✔ 62971...
Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata ✔ 62971...
 
Call Girls in Barasat | 7001035870 At Low Cost Cash Payment Booking
Call Girls in Barasat | 7001035870 At Low Cost Cash Payment BookingCall Girls in Barasat | 7001035870 At Low Cost Cash Payment Booking
Call Girls in Barasat | 7001035870 At Low Cost Cash Payment Booking
 
Independent Joka Escorts ✔ 8250192130 ✔ Full Night With Room Online Booking 2...
Independent Joka Escorts ✔ 8250192130 ✔ Full Night With Room Online Booking 2...Independent Joka Escorts ✔ 8250192130 ✔ Full Night With Room Online Booking 2...
Independent Joka Escorts ✔ 8250192130 ✔ Full Night With Room Online Booking 2...
 
Call Girls Agency In Goa 💚 9316020077 💚 Call Girl Goa By Russian Call Girl ...
Call Girls  Agency In Goa  💚 9316020077 💚 Call Girl Goa By Russian Call Girl ...Call Girls  Agency In Goa  💚 9316020077 💚 Call Girl Goa By Russian Call Girl ...
Call Girls Agency In Goa 💚 9316020077 💚 Call Girl Goa By Russian Call Girl ...
 
Russian ℂall gIRLS In Goa 9316020077 ℂall gIRLS Service In Goa
Russian ℂall gIRLS In Goa 9316020077  ℂall gIRLS Service  In GoaRussian ℂall gIRLS In Goa 9316020077  ℂall gIRLS Service  In Goa
Russian ℂall gIRLS In Goa 9316020077 ℂall gIRLS Service In Goa
 
Goa Call "Girls Service 9316020077 Call "Girls in Goa
Goa Call "Girls  Service   9316020077 Call "Girls in GoaGoa Call "Girls  Service   9316020077 Call "Girls in Goa
Goa Call "Girls Service 9316020077 Call "Girls in Goa
 
Top Rated Kolkata Call Girls Khardah ⟟ 6297143586 ⟟ Call Me For Genuine Sex S...
Top Rated Kolkata Call Girls Khardah ⟟ 6297143586 ⟟ Call Me For Genuine Sex S...Top Rated Kolkata Call Girls Khardah ⟟ 6297143586 ⟟ Call Me For Genuine Sex S...
Top Rated Kolkata Call Girls Khardah ⟟ 6297143586 ⟟ Call Me For Genuine Sex S...
 
CHEAP Call Girls in Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in  Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in  Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Almora call girls 📞 8617697112 At Low Cost Cash Payment Booking
Almora call girls 📞 8617697112 At Low Cost Cash Payment BookingAlmora call girls 📞 8617697112 At Low Cost Cash Payment Booking
Almora call girls 📞 8617697112 At Low Cost Cash Payment Booking
 
👙 Kolkata Call Girls Park Circus 💫💫7001035870 Model escorts Service
👙  Kolkata Call Girls Park Circus 💫💫7001035870 Model escorts Service👙  Kolkata Call Girls Park Circus 💫💫7001035870 Model escorts Service
👙 Kolkata Call Girls Park Circus 💫💫7001035870 Model escorts Service
 
𓀤Call On 6297143586 𓀤 Sonagachi Call Girls In All Kolkata 24/7 Provide Call W...
𓀤Call On 6297143586 𓀤 Sonagachi Call Girls In All Kolkata 24/7 Provide Call W...𓀤Call On 6297143586 𓀤 Sonagachi Call Girls In All Kolkata 24/7 Provide Call W...
𓀤Call On 6297143586 𓀤 Sonagachi Call Girls In All Kolkata 24/7 Provide Call W...
 
Call Girl Service Belur - 7001035870 with real photos and phone numbers
Call Girl Service Belur - 7001035870 with real photos and phone numbersCall Girl Service Belur - 7001035870 with real photos and phone numbers
Call Girl Service Belur - 7001035870 with real photos and phone numbers
 

3.2 stacks and arrays

  • 1. Microsoft® Small Basic Stacks and Arrays Estimated time to complete this lesson: 1 hour
  • 2. Stacks and Arrays In this lesson, you will learn about: Using different operations of the Stack object. Using different operations of the Array object.
  • 3. Stacks and Arrays Before we move on to discuss the Array object and the Stack object, let’s first understand when we use both of these objects. Arrays can be multi-dimensional, but a stack is only one-dimensional. You can use arrays to directly access any of its elements but if you use a stack, you can access only the top element. For instance, if you want to access the last element of the stack, you must go through all the elements from the beginning.
  • 4. The Array Object So far, you have learned about variables that store single values. Now, let’s learn about a special variable called an Array. An array is a type of variable that can store multiple values at a time. If you want to store the names of five users, then instead of creating different variables, you can just use one variable to store all of the five names. You use the indexing method to store multiple values in an array. For example, you can create an array called name as: name[1], name[2], name[3], name[4], and name[5]. Here, 1, 2, 3, 4, and 5 are the indices for the name array. The name[1], name[2]… may seem to you as different variables, but they are all just one variable!
  • 5. Operations of the Array Object You can use the IsArray operation to check whether the specified variable is an array. You can use the ContainsIndex operation to check whether the array contains the specified index. This operation is helpful when you want to check whether the array’s index is initialized by a specific value. You can use the ContainsValue operation to check whether the array contains the specified value. You can use this operation to check if the array’s value was stored in the specified index. Now, let’s discuss some operations of the Array object, such as IsArray, ContainsIndex, and ContainsValue.
  • 6. Operations of the Array Object As you can see, Subjects as an array stores the names of five different subjects. You can use the IsArray operation to check if Subjects is an array. You can also use the ContainsIndex operation to check the availability of the index Subjects[4] in the Subjects array. Lastly, you can use the ContainsValue operation to see if the value “Math” is available in the Subjects array. Let’s see how we can use these operations in a program. output
  • 7.
  • 8.
  • 9. Operations of the Stack Object The Stack object stores data just as a stack of plates. Let’s take a look at some examples to understand how it works. The PushValue operation is like adding a new plate to the top of the stack of plates. With the help of this operation, you can push a value to the specified stack. The PopValue operation is like picking out a plate from the top of the stack. You can use this operation to pop out a value from the specified stack. The GetCount operation provides the total number of plates in the stack. You can use this operation to determine the count of items in a specified stack.
  • 10. Operations of the Stack Object In this example, you use the PushValue operation to push 50 plates into an empty container. Then by using the PopValue operation, you take eight plates away from the stack. Now, use the GetCount operation to get the total number of plates in the container. You also display the value of the plate, which is placed at the top. Let’s write a program to better understand these operations.
  • 11. Let’s Summarize… Congratulations! Now you know how to: Use different operations of the Stack object. Use different operations of the Array object.
  • 12.
  • 13. Display the seat number of the passenger along with his or her name.
  • 14. Display the total number of seats available.

Editor's Notes

  1. Code:Subjects[1] = "English"Subjects[2] = "History"Subjects[3] = "Computers"Subjects[4] = "Science"Subjects[5] = "Math“TextWindow.WriteLine("Subjects is an array: " + Array.IsArray(Subjects))TextWindow.WriteLine("Subjects[4] is available: " + Array.ContainsIndex(Subjects, 4))TextWindow.WriteLine("Math is available: " + Array.ContainsValue(Subjects, "Math"))Array.GetItemCount(Subjects)
  2. Slide Notes:The PushValue operation does not return anything.The PopValue operation returns the value from the stack.The GetCount operation returns the number of items in a specified stack.
  3. Code:container = "empty"For i = 0 To 50 Stack.PushValue(container , "plate number " + i) EndForTextWindow.WriteLine("The number of plates in the container is " + Stack.GetCount(container))For i = 0 To 8Stack.PopValue(container) EndForTextWindow.WriteLine("After taking away 8 plates, the total number of plates is " + Stack.GetCount(container))TextWindow.WriteLine("The top most plate in the container is " + Stack.PopValue(container))
  4. Solution:TextWindow.WriteLine(“Flight Reservations")TotalSeats = 10For i = 1 To TotalSeatsTextWindow.Write("Enter Passenger Name: ") Name[i] = TextWindow.Read() TextWindow.WriteLine("Seat number " + i + " is reserved by " + Name[i])GetDetails()EndForSub GetDetailsIf Array.GetItemCount(Name) = TotalSeats ThenTextWindow.WriteLine("No more seats are available!")ElseArray.GetItemCount(Name)AvailableSeats = TotalSeats - Array.GetItemCount(Name) TextWindow.WriteLine("Number of available seats is: " + AvailableSeats)TextWindow.WriteLine("") EndIfEndSub