Arrays

9 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€66.45
List Price:  €94.93
You save:  €28.48
£55.32
List Price:  £79.03
You save:  £23.71
CA$98.04
List Price:  CA$140.06
You save:  CA$42.02
A$107.72
List Price:  A$153.89
You save:  A$46.17
S$94.09
List Price:  S$134.42
You save:  S$40.33
HK$544.68
List Price:  HK$778.15
You save:  HK$233.46
CHF 61.92
List Price:  CHF 88.46
You save:  CHF 26.54
NOK kr774.79
List Price:  NOK kr1,106.89
You save:  NOK kr332.10
DKK kr495.67
List Price:  DKK kr708.13
You save:  DKK kr212.46
NZ$118.82
List Price:  NZ$169.76
You save:  NZ$50.93
د.إ257.07
List Price:  د.إ367.26
You save:  د.إ110.19
৳8,339.40
List Price:  ৳11,913.94
You save:  ৳3,574.54
₹5,914.23
List Price:  ₹8,449.26
You save:  ₹2,535.03
RM311.24
List Price:  RM444.65
You save:  RM133.41
₦118,083.62
List Price:  ₦168,698.12
You save:  ₦50,614.50
₨19,391.36
List Price:  ₨27,703.14
You save:  ₨8,311.77
฿2,410.17
List Price:  ฿3,443.25
You save:  ฿1,033.08
₺2,423.71
List Price:  ₺3,462.60
You save:  ₺1,038.88
B$418.75
List Price:  B$598.25
You save:  B$179.49
R1,273.04
List Price:  R1,818.71
You save:  R545.66
Лв129.87
List Price:  Лв185.54
You save:  Лв55.66
₩97,732.12
List Price:  ₩139,623.30
You save:  ₩41,891.18
₪255.55
List Price:  ₪365.09
You save:  ₪109.53
₱4,110.61
List Price:  ₱5,872.56
You save:  ₱1,761.94
¥10,630.43
List Price:  ¥15,186.98
You save:  ¥4,556.55
MX$1,418.07
List Price:  MX$2,025.91
You save:  MX$607.83
QR254.36
List Price:  QR363.39
You save:  QR109.02
P953.37
List Price:  P1,362.02
You save:  P408.64
KSh9,063.70
List Price:  KSh12,948.70
You save:  KSh3,885
E£3,478.89
List Price:  E£4,970.06
You save:  E£1,491.16
ብር8,820.94
List Price:  ብር12,601.88
You save:  ብር3,780.94
Kz63,759.63
List Price:  Kz91,089.09
You save:  Kz27,329.46
CLP$68,404.72
List Price:  CLP$97,725.22
You save:  CLP$29,320.50
CN¥507.53
List Price:  CN¥725.08
You save:  CN¥217.54
RD$4,206.74
List Price:  RD$6,009.89
You save:  RD$1,803.14
DA9,351.13
List Price:  DA13,359.34
You save:  DA4,008.20
FJ$158.85
List Price:  FJ$226.94
You save:  FJ$68.09
Q538.41
List Price:  Q769.20
You save:  Q230.78
GY$14,600.65
List Price:  GY$20,858.96
You save:  GY$6,258.31
ISK kr9,615.92
List Price:  ISK kr13,737.62
You save:  ISK kr4,121.70
DH699.24
List Price:  DH998.96
You save:  DH299.72
L1,281.52
List Price:  L1,830.82
You save:  L549.30
ден4,084.06
List Price:  ден5,834.63
You save:  ден1,750.56
MOP$559.24
List Price:  MOP$798.95
You save:  MOP$239.71
N$1,266.15
List Price:  N$1,808.86
You save:  N$542.71
C$2,568.06
List Price:  C$3,668.81
You save:  C$1,100.75
रु9,427.87
List Price:  रु13,468.97
You save:  रु4,041.09
S/262.66
List Price:  S/375.25
You save:  S/112.58
K281.39
List Price:  K402.01
You save:  K120.61
SAR262.91
List Price:  SAR375.60
You save:  SAR112.69
ZK1,903.42
List Price:  ZK2,719.29
You save:  ZK815.86
L330.70
List Price:  L472.45
You save:  L141.75
Kč1,679.39
List Price:  Kč2,399.23
You save:  Kč719.84
Ft27,552.80
List Price:  Ft39,362.83
You save:  Ft11,810.03
SEK kr765.72
List Price:  SEK kr1,093.94
You save:  SEK kr328.21
ARS$70,549.59
List Price:  ARS$100,789.45
You save:  ARS$30,239.85
Bs482.26
List Price:  Bs688.98
You save:  Bs206.71
COP$307,907.55
List Price:  COP$439,886.78
You save:  COP$131,979.23
₡35,643.95
List Price:  ₡50,922.11
You save:  ₡15,278.16
L1,765.02
List Price:  L2,521.57
You save:  L756.54
₲545,488.80
List Price:  ₲779,303.12
You save:  ₲233,814.31
$U2,997.83
List Price:  $U4,282.79
You save:  $U1,284.96
zł286.31
List Price:  zł409.03
You save:  zł122.72
Already have an account? Log In

Transcript

Welcome back. Now you're in lesson 16. And in this lesson, we're going to talk about arrays. So what is an array? Well, remember when we talked about a variable where if you create a variable, you can put a value in it and store it there for whenever you need it. Arrays are very similar to that.

The difference is a variable, you can only store one value in an array, you can store a whole group of values. It's easier whenever you have a large number of similar items, it must be initialized. So what we're saying here is remember when we when we initialize a variable, and we say number is equal to five, for example, so number equal to five is actually initializing it, declaring it we'll just say, if we have an number, then that would be declaring it but initializing it is actually assigning it in a value. So when you start your array, you actually have to enter initialized it, okay, declare integer units as an example of pseudocode here where we're declaring that we have this array called units. It is of integer type. And we want three positions.

So we want to put a value in three different positions much easier than having to use three different variables, especially when it's a similar collection item of some sort. Okay, so the thing to remember with an array though, is it always starts at zero. If you look at the bottom here, where I have units, zero equals six, that shows you how to access the position in that array. So in code, you would say units because that's the name of your array, you use the zero position because that's the first position within the array, and then you're assigning a value of six to it. Because that's the number that you want in that array. Same thing you one two and units two, seven.

Always remember, if there's nothing else you remember about it right make sure you remember that it always starts with zero in the position and that's how you access the position. Because if you have an array of 10 and you put in the number 10, you're going to get a compilation error because it starts at zero there is no position 10 you can create an array of 10 but that starts at 00123456789. That is 10 position. So always remember that anything remember it always starts with a zero. So you might ask yourself, Is there another way that I can step through the all the positions in an array besides just having to list the position that that value is in and there is there is you can actually use a loop in order to step through an array for number equals zero to nine set series index equal to 104.

If you look at that example, you would use the for statement in order to step through the loop. Now, depending on the language if for statement is going to be written quite differently, so just keep that in mind. This is pseudocode, we're saying for number equals 09 series and then we want you to know in the brackets that that's the index and then equal to 104. So basically, each position in the array is called an index. And if you say index zero, then that would be the first position in an array. Okay?

If you said index 10 that would be the 10th position in array if that array is variable, but you can use the Force statement to step through it So there are a lot of things that you can do with the ray which when I get more classes put on here, I'm going to go into more detail as we get into the further language. But right now, I just want you to know that there are more things that you can do with an array. So you could find the lowest value in an array, you could find the highest value in an array, you could find a value at a specific index in an array. You could even do math computations in array like you could sum everything up that you had and having an array so you have the ability to search the array to and so with all that, think of any kind of List of anything where maybe you were doing a list of of sales for that day it would be great because it since you can do math computations, you can keep it all in array and then just have it automatically added Everything in at the end.

And here are some more different types of arrays. So I hope you can see that when you start getting into the programming language itself, you're going to be learning about all different kinds of ways that you can work with arrays, there are jagged arrays, where maybe you don't have the the array made with all filled up with data. What I'm saying here is that an array doesn't shrink, or grow by the data that you put in it, you set a specific amount, and that's all you can use. And so with a jagged array, what happens is maybe you don't have all of those spaces field. So that's called a jagged array because you're going to have some empty spaces in there. Sometimes you don't have enough data to fill that array up.

But again, you can't Change the size and array. So you want to leave open more availability for somebody to put it in there. I mean, if you just think about an invoice system for a company, they need to have extra room in order to build sales. So you don't know how much they're going to sell later on down the line. If you were to use an array with that, even with daily sales, you would have to give them plenty of room to put that information in there. There are parallel arrays, so arrays that kind of work side by side there.

There's two dimension arrays, which if if you think about the two dimension as the three or more dimension arrays, then you're you're mean to know a little bit about Excel because it works a lot more like an Excel program where you have a lot of rows and columns and cells. And so I would encourage you as you're going to work in programming, to learn as much as you can about Everything that you can all will be wonderful knowledge for you in the future. And I run into all the time, students that don't understand the basics when they're programming students, because they don't always get taught a lot of those basics, but it will really help your understanding. So everything that you can learn is all going to be helpful for you. I'll talk more about those types of rays in detailed classes further on. But at this point, just know that they exist.

And then there is that availability. Well, look at that. We're all done with the rays and you made it through another one of my videos, I am so proud of you. Make sure that you just keep doing the stuff over and over and over again and get it in your brain and get those main concepts down. Because when you take another class, like if you take introduction to Python or if you take an app Introduction to C sharp or any of those programs. All the things that we're going to talk about, or that we talked about in this class, are going to be in much more detail in the next one, you know, it's just important to get some base knowledge down before you get into all those details, because there's so much to it and so much to remember.

So I just just want to encourage you to just keep trying and keep at it. Programming is not easy. It's not something that people just automatically jump into. And I know that's what we see all the time in the movies and we think, Oh, this person is just boom. They're just a genius at programming. That is a rarity.

I promise you and it does take time and it does take practice and it does take knowledge and it does take learning from others and researching by Programming is still one of the few things that you can learn how to do, and go get a job and you don't need a degree for it. So I'm really glad that you're here because learning is where it all begins.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.