All language subtitles for 17. Subtracting EvenDigitsSum and OddDigitsSum - Solution

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
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
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

What is going on, guys?

And welcome back to another exercising our programming or C C programming course, any of these exercises,

what you are requested to do is to find the difference between the sum of all even numbers of all even

digits as they are and the sum of all odd digits in a given number.

So what we are going to do is to write a function that receives, receives, let's say, receives some

number and the function is going to do the following.

The function is going to find it.

Say that Ngong was, I don't know, seven thousand four hundred and fifty two.

And the song, the function to program.

We haven't covered a function yet.

In the next section I think we are going to talk about it.

They are this program is going to do something very, very simple.

We are going to calculate the sum of all even our digits so we get even digits some equals to simply

four plus two, which is six.

All right.

And then we are going to calculate the order, the digits sum, which in this case is simply seven plus

five, which is a total of 12.

And once we found out the even digits in the digits, we are going to print the even digits sum minus

the odd digits.

So that's basically all that we have to do in this program.

So with that being said, let's dive right away into coding.

So the first question that you should have is how basically you can find and calculate the digit of

every basically calculate and take into account the value of every digit.

So for that list, first of all, create the additional variable and Colignan and read these num from

the user.

So answer Anom with this value and store it inside now.

OK, so that percentage is storing it inside of numbers.

Once you are done with these borith, let's simply think about.

So we need to sum the even digits and we also need to sum the odd digits.

So one way to do so is to create additional variable and call it, let's say even some equals to zero

and all the sum equals to zero.

So that's how we start solving this exercise.

And now what do we have to do is simply start each rating over our given num in basically every time

on every iteration to take the rightmost digit into the sum.

So how it will look like let's first of all create or better say we don't need to create anything here.

So let's say as long as NUM is greater than.

Than what than zero.

Right.

As long as it has at least one digit.

Yeah.

Which is not zero of course.

Then in these case we are going to do is what you ask the following question if ok if let's it or take

it like this also creates additional variable, let's create a digit or current digit.

OK, so if current digit.

OK, what is current digit.

Let's define it.

So current digit equals two nom more Lutin.

OK, so it simply will give you the rightmost digit of num.

All right.

So if we have like seven, four or five to these current digit will be two, OK, because we try to

divide it by ten and that's the remainder which is left, which is two.

So if current digit divided modulo two equals three zero, then it means the current digit current digit

is even.

So in this case, what we should do is simply use even some equals to the previous, even some plus

plus one plus the current digit.

Exactly.

Else, if that's not the case, meaning that current digit is odd, that in this case we have odd some

equals to the previous odd some lost current digit.

So that's OK.

So let's hope that's clear.

So let's just remove this and.

The appropriate signs while sequels to this one, OK, so taking even some of the previous value and

adding to the current Egypt or taking the old songs and adding to the current Egypt.

So basically that's how the for loop these while loop looks like.

And one thing that we still haven't talked about and we didn't add, we haven't added the last line.

Think about it for a second.

What's missing here in the body of this loop?

Basically, this loop is for now kind of infinite loop.

We simply take no, we get the rightmost Egypt, which is still in the next iteration, we will still

get two and and so on and so forth, will always get the right moves.

Egypt is still because now will forever remain greater than zero.

So what we have to do is that once we have taken into account these rightmost Egypt, we should simply

change them from this value to seven, four or five.

Right.

Because we don't need any more of these kind of Egypt.

So how do you do it?

You simply say not goes to the previous number divided by 10.

OK, so when you divide it by 10, you will simply get seven, four or five and that's it.

And that's how you continue working.

Then you are simply working with seven, four, five and you just get the rightmost digit, which is

five, and then you get the right digit, which is four.

And right afterwards you get the right most digit, which is seven, and the final result is going to

be zero.

And this condition is going to be false.

And basically you'll be out of these while loop.

So finally, what you will have to do is just print.

OK, so printf who what do you have to print?

Even aged some minus the odd digit sum equals equals to want to present the D backslash.

And it will be like even some minus odd some.

OK, so that's what our program is all about.

And now let's build and run it to see that everything works as expected.

So international.

Let's go with it like one three, five, eight and six.

So we know that we have the even will be 14 minus nine which should give us even digits, minus all

digits, a total of five.

So everything seems to be working correctly.

Let's go like six, five, four.

It should give us five once again.

Awesome.

So you guys, this is it for this video.

I hope you enjoyed it.

Please let me know if you still have any questions, and I'll see you next time.

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