for Loop

2 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€93.69
List Price:  €131.17
You save:  €37.48
£77.60
List Price:  £108.65
You save:  £31.04
CA$139.29
List Price:  CA$195.02
You save:  CA$55.72
A$151.87
List Price:  A$212.63
You save:  A$60.75
S$133.13
List Price:  S$186.38
You save:  S$53.25
HK$777.29
List Price:  HK$1,088.24
You save:  HK$310.95
CHF 87.93
List Price:  CHF 123.11
You save:  CHF 35.17
NOK kr1,104.77
List Price:  NOK kr1,546.73
You save:  NOK kr441.95
DKK kr698.68
List Price:  DKK kr978.18
You save:  DKK kr279.50
NZ$167.57
List Price:  NZ$234.61
You save:  NZ$67.03
د.إ367.26
List Price:  د.إ514.18
You save:  د.إ146.92
৳12,019.14
List Price:  ৳16,827.28
You save:  ৳4,808.14
₹8,437.49
List Price:  ₹11,812.83
You save:  ₹3,375.33
RM440.95
List Price:  RM617.35
You save:  RM176.40
₦168,038.19
List Price:  ₦235,260.19
You save:  ₦67,222
₨27,930.87
List Price:  ₨39,104.34
You save:  ₨11,173.46
฿3,435.35
List Price:  ฿4,809.63
You save:  ฿1,374.28
₺3,432.75
List Price:  ₺4,805.99
You save:  ₺1,373.23
B$578.39
List Price:  B$809.77
You save:  B$231.38
R1,775.91
List Price:  R2,486.34
You save:  R710.43
Лв183.06
List Price:  Лв256.30
You save:  Лв73.23
₩139,696.36
List Price:  ₩195,580.49
You save:  ₩55,884.13
₪373.04
List Price:  ₪522.27
You save:  ₪149.23
₱5,864.11
List Price:  ₱8,209.99
You save:  ₱2,345.87
¥15,367.99
List Price:  ¥21,515.80
You save:  ¥6,147.81
MX$2,036.44
List Price:  MX$2,851.10
You save:  MX$814.65
QR365.08
List Price:  QR511.13
You save:  QR146.04
P1,334.01
List Price:  P1,867.67
You save:  P533.65
KSh12,898.71
List Price:  KSh18,058.71
You save:  KSh5,160
E£4,921.85
List Price:  E£6,890.79
You save:  E£1,968.94
ብር12,453.44
List Price:  ብር17,435.32
You save:  ብር4,981.87
Kz91,125.91
List Price:  Kz127,579.93
You save:  Kz36,454.01
CLP$97,077.66
List Price:  CLP$135,912.62
You save:  CLP$38,834.95
CN¥719.49
List Price:  CN¥1,007.32
You save:  CN¥287.82
RD$6,057.20
List Price:  RD$8,480.32
You save:  RD$2,423.12
DA13,406.48
List Price:  DA18,769.61
You save:  DA5,363.12
FJ$225.25
List Price:  FJ$315.36
You save:  FJ$90.11
Q777.28
List Price:  Q1,088.22
You save:  Q310.94
GY$21,042.91
List Price:  GY$29,460.92
You save:  GY$8,418
ISK kr13,914.60
List Price:  ISK kr19,481
You save:  ISK kr5,566.40
DH993.26
List Price:  DH1,390.60
You save:  DH397.34
L1,803.93
List Price:  L2,525.57
You save:  L721.64
ден5,764.94
List Price:  ден8,071.14
You save:  ден2,306.20
MOP$805.37
List Price:  MOP$1,127.55
You save:  MOP$322.18
N$1,760.19
List Price:  N$2,464.34
You save:  N$704.14
C$3,701.17
List Price:  C$5,181.79
You save:  C$1,480.61
रु13,577.81
List Price:  रु19,009.47
You save:  रु5,431.66
S/377.27
List Price:  S/528.20
You save:  S/150.92
K403.78
List Price:  K565.32
You save:  K161.53
SAR375.56
List Price:  SAR525.80
You save:  SAR150.24
ZK2,738.35
List Price:  ZK3,833.81
You save:  ZK1,095.45
L466.14
List Price:  L652.62
You save:  L186.47
Kč2,371.47
List Price:  Kč3,320.16
You save:  Kč948.68
Ft38,315.49
List Price:  Ft53,643.23
You save:  Ft15,327.73
SEK kr1,086.64
List Price:  SEK kr1,521.34
You save:  SEK kr434.70
ARS$99,364.60
List Price:  ARS$139,114.41
You save:  ARS$39,749.81
Bs696.54
List Price:  Bs975.19
You save:  Bs278.64
COP$434,893.49
List Price:  COP$608,868.29
You save:  COP$173,974.79
₡51,449.82
List Price:  ₡72,031.81
You save:  ₡20,581.98
L2,537.81
List Price:  L3,553.04
You save:  L1,015.22
₲786,505.60
List Price:  ₲1,101,139.31
You save:  ₲314,633.70
$U4,173.81
List Price:  $U5,843.51
You save:  $U1,669.69
zł406.70
List Price:  zł569.40
You save:  zł162.69
Already have an account? Log In

Transcript

Hello, in this video, I am going to cover the for loop. So the for loop is pretty simple allows you to loop a certain amount of times. And you can have as much code as you want whoever code you want. So there's three main parts in the for loop. So we got, so we do fall in here, the three main parts, and they are separated by a semicolon. So the first part is any variable declaration and initialization.

So we're going to have dollar oil. And so that's created if it doesn't already exist, and we're going to assign a value of zero to it. You could have more like so if you want to. The second part is the condition. So we're gonna say, while i is less than 10, we're going to keep running it we're gonna keep running. And then the final part is basically a little piece of code that is right at the end of each pass of the loop.

This is usually two modify this variable somehow, you could do this modification within the loop. If there's some condition that hasn't been met, that's fine. But this will just always run at the end of each path. If we do you know, something like this, this just adds one to our using the increment operator. And if I was to echo out, let's echo out I and we will also put a brake line Actually, I can just put quotation marks and put dollar inside this will be a lot easier. So as you can see, we have 0123456789.

So it starts at zero because that's where the number starts. It does not print out 10 because this is less than 10. So once it hits 10, it's no longer gonna run for less than or equal to 10. As you can see, that is now up to 10. And this can start at any particular point in time. You can see right there.

So really, there's not much else to for loops that you really need to know you can put as much code as you want in here, and that is what gets run. And yeah, uh, what I want you to do as an extra task is, remember the arrays, video, we're going to combine arrays with a for loop. So basically, I'm going to be able to print out every piece of information in the array without having to manually specify its you know, index zero, then I'm printing it index one, index two, because if if, let's say the array had 100 values, that really, really tiresome to access each value and print them out. I want you to adapt a for loop for that. And if you have any questions, feel free to pop me a message. And as usual, I look forward to seeing you in the next video.

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.