All language subtitles for 16. Increment and Decrement Expressions

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French Download
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 0 1 00:00:00,680 --> 00:00:06,800 Now so far what we have seen are all operators that exist in normal mathematics. 1 2 00:00:07,020 --> 00:00:10,970 But here are some that only exist in programming. 2 3 00:00:11,310 --> 00:00:14,050 So take a look at this expression. 3 4 00:00:14,070 --> 00:00:17,590 We create a variable called x and we set it equal to 5. 4 5 00:00:17,700 --> 00:00:23,760 Then we change the value of x to the previous value, which is 5, plus 1. 5 6 00:00:23,880 --> 00:00:26,070 So x now equals 6. 6 7 00:00:26,070 --> 00:00:29,790 Now we've seen this and we've been using this in our previous code. 7 8 00:00:29,850 --> 00:00:31,870 So this should be familiar to you already. 8 9 00:00:31,920 --> 00:00:39,360 But in most programming languages, instead of writing out x = x + 1, you can simply write 9 10 00:00:39,420 --> 00:00:49,260 x++, and, in exactly the same way, x now gets incremented by 1 and is now equal to 6. So x++ 10 11 00:00:49,650 --> 00:00:56,760 is the equivalent of saying x = x + 1, and this is called the increment expression. 11 12 00:00:56,760 --> 00:00:58,740 Now you can go the other way as well. 12 13 00:00:58,740 --> 00:01:00,950 You can write x--, 13 14 00:01:01,080 --> 00:01:05,250 and this is equivalent to x = x - 1. 14 15 00:01:05,280 --> 00:01:10,650 So the previous value of x, 5, minus 1, so x now equals 4. 15 16 00:01:10,920 --> 00:01:13,440 And this is called the decrement expression. 16 17 00:01:13,440 --> 00:01:20,670 Now you might have heard of the programming language C and C++, and this is kind of like a programmer's 17 18 00:01:20,670 --> 00:01:24,720 idea of a good joke, even though nobody else thinks it's funny. 18 19 00:01:24,750 --> 00:01:31,100 But essentially C++ was meant to be an increment on the C programming language. 19 20 00:01:31,110 --> 00:01:37,920 So it's kind of like C plus one, a little bit better than C. Remember that with ++ and --, 20 21 00:01:38,040 --> 00:01:40,890 you're only ever changing the value by one. 21 22 00:01:40,890 --> 00:01:47,790 Now if you ever want to increase the value of x by more than one, then you can use the +=, and 22 23 00:01:47,800 --> 00:01:52,280 this is equivalent to saying x = x + 2. 23 24 00:01:52,350 --> 00:01:55,400 And so x now equals 7. In the same way, 24 25 00:01:55,410 --> 00:02:00,530 you can also use += to increase by the value of another variable. 25 26 00:02:00,540 --> 00:02:05,370 So in this case x = x + y, which is equal to 8. 26 27 00:02:05,370 --> 00:02:10,270 And this also works with -=, *=, /=, 27 28 00:02:10,410 --> 00:02:13,850 and it's a handy shorter way of doing exactly that. 28 29 00:02:13,860 --> 00:02:15,660 So, in the next lesson, 29 30 00:02:15,690 --> 00:02:19,620 I have a brief quiz for you to see if all of this stuck 30 31 00:02:19,740 --> 00:02:21,390 and if it makes sense. 31 32 00:02:21,480 --> 00:02:27,300 So head over there and see if you can complete the multiple choice question and I'll see you on the 32 33 00:02:27,300 --> 00:02:28,190 next module. 3236

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.