Range-Based For Loop

3 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
€85.49
List Price:  €119.70
You save:  €34.20
£74.12
List Price:  £103.78
You save:  £29.65
CA$136.71
List Price:  CA$191.41
You save:  CA$54.69
A$152.23
List Price:  A$213.13
You save:  A$60.89
S$128.04
List Price:  S$179.26
You save:  S$51.22
HK$784.91
List Price:  HK$1,098.91
You save:  HK$313.99
CHF 79.62
List Price:  CHF 111.47
You save:  CHF 31.85
NOK kr1,010.40
List Price:  NOK kr1,414.60
You save:  NOK kr404.20
DKK kr638.01
List Price:  DKK kr893.25
You save:  DKK kr255.23
NZ$166.83
List Price:  NZ$233.57
You save:  NZ$66.74
د.إ367.26
List Price:  د.إ514.18
You save:  د.إ146.92
৳12,155.75
List Price:  ৳17,018.53
You save:  ৳4,862.78
₹8,596.36
List Price:  ₹12,035.26
You save:  ₹3,438.89
RM425.20
List Price:  RM595.30
You save:  RM170.10
₦153,097.68
List Price:  ₦214,342.88
You save:  ₦61,245.20
₨28,434.65
List Price:  ₨39,809.65
You save:  ₨11,375
฿3,238.52
List Price:  ฿4,534.06
You save:  ฿1,295.54
₺4,019.29
List Price:  ₺5,627.17
You save:  ₺1,607.88
B$555.95
List Price:  B$778.35
You save:  B$222.40
R1,785.64
List Price:  R2,499.97
You save:  R714.33
Лв167.37
List Price:  Лв234.32
You save:  Лв66.95
₩138,035.24
List Price:  ₩193,254.86
You save:  ₩55,219.61
₪336.32
List Price:  ₪470.86
You save:  ₪134.54
₱5,662.23
List Price:  ₱7,927.35
You save:  ₱2,265.11
¥14,719.04
List Price:  ¥20,607.25
You save:  ¥5,888.20
MX$1,867.78
List Price:  MX$2,614.97
You save:  MX$747.18
QR364.02
List Price:  QR509.64
You save:  QR145.62
P1,334.67
List Price:  P1,868.59
You save:  P533.92
KSh12,918.70
List Price:  KSh18,086.70
You save:  KSh5,168
E£4,944.50
List Price:  E£6,922.50
You save:  E£1,977.99
ብር13,688.63
List Price:  ብር19,164.63
You save:  ብር5,476
Kz91,186.38
List Price:  Kz127,664.58
You save:  Kz36,478.20
CLP$95,820.41
List Price:  CLP$134,152.41
You save:  CLP$38,332
CN¥716.71
List Price:  CN¥1,003.43
You save:  CN¥286.71
RD$6,029.39
List Price:  RD$8,441.39
You save:  RD$2,412
DA13,004.72
List Price:  DA18,207.13
You save:  DA5,202.41
FJ$224.44
List Price:  FJ$314.23
You save:  FJ$89.78
Q767.92
List Price:  Q1,075.11
You save:  Q307.19
GY$20,914.76
List Price:  GY$29,281.51
You save:  GY$8,366.74
ISK kr12,176.78
List Price:  ISK kr17,047.98
You save:  ISK kr4,871.20
DH900.15
List Price:  DH1,260.25
You save:  DH360.10
L1,693.89
List Price:  L2,371.51
You save:  L677.62
ден5,262.76
List Price:  ден7,368.08
You save:  ден2,105.31
MOP$808.30
List Price:  MOP$1,131.65
You save:  MOP$323.35
N$1,772.82
List Price:  N$2,482.02
You save:  N$709.20
C$3,674.63
List Price:  C$5,144.63
You save:  C$1,470
रु13,711.85
List Price:  रु19,197.15
You save:  रु5,485.29
S/354.61
List Price:  S/496.47
You save:  S/141.86
K412.45
List Price:  K577.45
You save:  K165
SAR374.98
List Price:  SAR524.99
You save:  SAR150
ZK2,314.16
List Price:  ZK3,239.92
You save:  ZK925.75
L434.44
List Price:  L608.23
You save:  L173.79
Kč2,108.91
List Price:  Kč2,952.57
You save:  Kč843.65
Ft34,214.75
List Price:  Ft47,902.02
You save:  Ft13,687.27
SEK kr958.89
List Price:  SEK kr1,342.49
You save:  SEK kr383.59
ARS$126,065.09
List Price:  ARS$176,496.17
You save:  ARS$50,431.08
Bs692.26
List Price:  Bs969.19
You save:  Bs276.93
COP$401,329.80
List Price:  COP$561,877.77
You save:  COP$160,547.97
₡50,416.70
List Price:  ₡70,585.39
You save:  ₡20,168.69
L2,634.73
List Price:  L3,688.73
You save:  L1,054
₲774,763.12
List Price:  ₲1,084,699.36
You save:  ₲309,936.24
$U4,064.43
List Price:  $U5,690.36
You save:  $U1,625.93
zł364.14
List Price:  zł509.81
You save:  zł145.67
Already have an account? Log In

Transcript

Hello, welcome to the 26th tutorial in the c++ programming series. And in this problem we're looking at range basically arraign basically has a slightly different syntax which is used to loop through basically ranges of data instead of looping based around a condition. Let's show you how to use the rain base loop. And in many ways, you can just do the regular loop and make do the same thing in the rain. Basically, you have to do a lot of extra stuff yourself and if all you're going to be doing for this particular in that particular instance, denim rain basically is best when the first is in clewd truing other women just looping through a string in the string str to us, the std namespace as to We are just going to simply sown the value, hello, world. And what we're going to do is for the syntax is for log for loop inside instead of doing the first statement, which is set up in a variable.

The second statement is the condition the first statement, which is usually like incrementing or decrement in the variable manipulating them somehow. What you just do is do like char C, we because string is made up of characters, like hate to the creditor, or the counter space in the theater, yes, it was basically theater, and you do cola FTR. So basically what this means is, you'll look for this and every time the big three c will be the next character in this truing code STL which is well this one here. The dudes do STD see we are going to see STD and then if we just run it we have hello world HelloWorld printed out but because obviously print new line character they're all new 9.7 in a space is put each crate on a new line but a lot of us to loop through it and get every single character instead of trying to set up an incrementer Gehring, the length of the string, then getting a particular position in the string based on our iterator.

This is just a lot easier but obviously as you can say, it's a lot more limited compared to a for loop and you generally wouldn't substitute this for a lot of foliage this just well arranged grateful. That is it for this tutorial. If you have any questions, feel free to message c++ support systems. The Cody Kay email window description comment on this video to start getting messages via YouTube as well. In the next part, we'll be looking at the go to statement. All the recording for source code will also be in the description.

And as usual, thank you for watching and I hope you have a nice day.

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.