Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
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.