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
Hoo hoo hoo hoo hoo hoo.
Ed. Long exercise in our programming, programming, programming, C programming language.
OK, so let's go another exercise, huh?
So what do we have to do here is to write a program.
What is the program?
What is this program should do?
It's a program that receives three integers, so we should receive three integers.
And based on these three integers, we know that there may be a couple of beers.
Right.
So, for example, our integers are going to be A, B and C, OK, now one and two and three.
Then from A, B and C, we can generate a couple of pairs.
So there may be a pair like A and B, there may be a pair of like B and C and there may be also a player
like A and C, OK, so there are only three pairs that may be generated, three unique pairs from this
sequence of three integers.
And basically what we should do is simply to take each pair and see if we can take either B and divided
by A without a remainder or taking A and dividing it by B without the remainder and do the same process
for these pair.
And also four.
That's better.
And finally, if we could find that each pair contains it, it has at least one value that can be divided
by the other without any remainder.
Then in this case we should simply print something like what was advisable.
OK, otherwise we should print not divisible.
OK, so that's just the simple exercise to practice your knowledge and your skills of using conditions.
Again, just some logic.
So let's start by getting first of all, let's create the variables, read the values from the user
and later on construct our condition so that we'll look something like this.
So let's say No.
One and two and three, OK, or better say let's go with A, B and C showing A, B and C, so int A,
B and C, and in this case we are going to use print F cancer and her and her answer a OK.
And then the user will specify A and we will use an F to read the value to a K to A or basically let's
just use one kind of command to read all of them.
So those kind of percentage will have a three percentage lead once again.
Once again, answer A, B, B and C, OK, that's what the user is going to insert in this line.
We will read all the three integers from the screen and store them inside variables A, B and C, awesome.
So now that we have all of this information, let's start thinking about what should be the condition.
So the condition is constructed.
It's going to be very on condition.
So prepare yourself, maybe grab something to drink.
Yeah.
So the condition is going to do the following thing.
We will check if we can divide B, OK, we'll take all the pairs.
Right.
There are three total of three pairs and we will take for each pair.
We'll test out two conditions if B can be divided by eight without the remainder.
And also if it's not the case, we will check if eight can be divided by B without a remainder.
OK, and we will repeat these process in checking also for the player and for the last pair.
So how it will look like that's first of all, start with a single F f so we know that if A can be divided
by B without a remainder then that's OK.
And if it's not something that is possible, then let's check if we maybe can be divided by a without
a remainder.
So if A can be divided by B without the remainder or beacon divided by A without a remainder, then
we know that these pair will return.
True right.
B, A and B will return true.
So that's not enough to print divisible numbers.
What we have to do is check also the two other pairs.
So we will see and and what will happen in the next pair.
So if B can be divided by C without a remainder in or OK or C can be divided by B without the remainder,
because even if one of them can be divided by the other without a remainder, that's also OK.
And then if that's the case then.
We need to check the third the third pillar, which is if a can be divided by sea without the remainder
or C can be divided by a without a remainder.
So if you can see here, we have two and logical operators.
So if one pair does not or does not happen to satisfy this condition, then the whole result will return
or basically print, not divisive.
But if all of them, all the Paris has at least one value that can be divided by the other value without
a remainder.
And in this case, we will simply print divisive the visible numbers.
All right.
So that's how we are going to do it.
But if at least one of them OK, one of them, OK, that's the first bear.
The comparison for the first bear, this second bear and the third bear.
And in each bear, it's sufficient that at least A, maybe divided by B or be divided by A, they don't
have to both of them be divided by one another.
Right.
So if one parent does not satisfy the condition, then in this case we will use the L's statement and
printf not divisive numbers.
OK, guys, so that's how we do it.
Not divisible numbers.
Awesome.
So the condition maybe not so straightforward from our first glance, but I think that if we take additional
look and try to understand it even further, that's not so, so scary process, is it?
So let's build and run it and let's see what happens.
So answer A, B and C. So we had an example like five, 10 and 20 and these numbers were advisable.
So divisible numbers are awesome.
And let's use another example, like two, four and seven, where we know that two and four are kind
of divisible.
Four, it can be divided by two.
But seven is the odd number here.
And it's kind of problematic.
So let's say not divisible numbers.
OK, so you see that this program seems to be working correctly, but there may be some problem when
doing the following thing.
Let's try to build and run it and let's see what happens.
So let's say we have five, we have 10 and we have zero.
Then in this case, probably we will or our program is going to crash or we will get some very strange
number that a process return not zero like it should if we succeeded, but some other a number and we
didn't get any result for whether it's divisible or not divisible.
So that's something good that happens, that we still just get some unexpected result.
But sometimes the program may also crash and also you may get some unexpected results that you will
not know from where it all started.
So the problem here is very simple and but we should address it properly.
And it says that what will happen if we will try to divide by zero and we know that the division by
zero is not optional and it's not possible.
So in this case, what I recommend you to do is simply to add before you use these this kind of division
check, simply add additional condition to check if A equals to zero.
Right.
If A equals to zero or if B equals to zero.
Or you've see equals three zero.
If either of them equals to zero, then in this case, let's bring some message.
Printf cannot divide by zero.
Check your check your input once again.
It's something like this, some descriptive message to the user.
But if not, if it's not the case, if all of them, A, does not equal to zero, B does not equal to
zero and C does not equal to zero, then in this case, let's execute these else if OK and finally execute
the else.
So that's how you kind of prevent unexpected behavior and also some unexpected errors and youguys.
So we covered how to take three integers and to see if they can be divisible by by dividing them into
pairs and if there is at least one number that can be divided by the other without a remainder.
So, as always, thank you so much for watching.
Thank you so much for practicing and listening.
And my suggestion is close now.
This exercise and the solution actually open up the exercise itself and try to solve it on your own.
Make sure that the program that you create and you run will be pretty much the same, like the one we've
created.
So good luck, guys, and I will see you in the next exercises.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.