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 now that you are familiar with what are conditions and what they are used for, let's see how we
can use them and implement them in C programming language.
Let's start with our previous congratulations example, where we have to get a grade as an input.
And if these grade equals or higher than 60, then we just printed out congratulations.
Otherwise printed out a field.
Try again, Masad.
And if we know that we write these programming C language, let's first of all start with our well-known
pirates.
So let's use the includes include SDD, TDA, old age and include SDD Liebe.
These are basically the two default included that we've seen in code blocks in our code examples in
the previous videos.
And now we also know that we need some starting point.
Right.
Perhaps we can also write these main thing.
Already there int Main and the curly brackets to hold the block of commands.
Great.
And now we know that we have to get the grade as an input from the user.
So let's first of all declare these variable use in to grade.
We created a variable called the gradient.
And these of type end.
And then we will simply read the value from the user using scan F and hold this value inside of these
variable.
And up until now, everything seems to be as usual and write nothing new.
So I think that's the time we should add the condition.
And actually, that's pretty simple.
We just write the EEF statement and after war, as we specify the condition in the parentheses.
So the condition in this case is simply if greyed equals or higher than 60.
And now we can specify the commands that should be executed once the condition happens to be true.
So in this case, we should simply use the printf command to just display a congratulations message
on the screen.
If the grade is actually higher or equals to 60.
So that's all good and nice.
And if we currently build an R&D program there, this program will be just capable of printing.
Congratulations.
Message only is the result of the condition is true.
If the result of the condition is false.
All right.
So basically nothing will happen here.
The program just will read that the value from the user.
But it will not print anything to the screen.
You may try to ram this code at home.
Simply enter, I dunno, 50 and see what happens in the.
You probably will see that nothing will happen.
So that's why you would like to specify in the condition itself what commands should be executed if
the result of the condition is false.
Right.
We have here what will happen if the result is true.
If the if the result of the condition is true.
We also want to specify what will happen if the result of the condition is false.
So how can we do it?
How can we print the field?
Try again.
Message to the screen.
If the condition is false, it simply should add the else section, meaning all the commands that will
happen if the grade is less than 60.
So then you will just print fail, try again.
And there you go.
And actually, that's pretty simple, right?
Nothing complicated.
Just an F and a bunch of commands and that may be executed based on the result.
If it's true and an ls the some other commands that that may be executed if the result of the condition
is false.
So now I want us to get over this code line by line and make sure that we fully understand its flow,
meaning what lines are going to be executed before and after and simply how the the program that your
computer is going to execute these code.
And before you finish.
Just don't forget to add the return zero at the end to specifying that there that the program has been
terminated.
Successful.
All right.
So the steps are as follows.
We, first of all, start in the main block.
Then we declare our first variable, the integrated.
Then we read the value from the user by using the scanner function.
And let's say that the value in this case was, I don't know, something like 90.
And now we should just use the condition.
And ask QIf grade is greater or equals to 60, which happens to be true.
And if that's the case, we print that congratulations message to the screen.
And then, of course, we skip the LS part because it should only be executed when the condition is
false.
Which is not the.
Case, and you just returned the zero.
And there you go.
That was basically the flow for how your computer will execute this code line by line if the grade received
from the usery will equal to 90 in this case.
And now let's take a look at the flow of the program.
When we receive a grade that is actually less than 60.
So you create a variable as previously.
And then you read the value of the grade, which in this case, we assume that it will be just fifty,
let's say.
And then you come to the conditions section, which in this case happens to be false.
Right.
Fifty is not greater than 60.
So if it's not true, you don't run the print.
Congratulations.
Message through the screen.
You simply move to the yellow section.
And now you execute the commands of the else block.
You simply print failed.
Try again message.
Then you move on to the return zero.
And there you go.
Your program is complete.
So that basically was, guys, the second flow of how the computer will Iran this code.
If a given grade from the user is actually less than 60.
So we will not run.
It will not execute the code under the EEF section.
It will simply go to the else and just execute the print command stated there.
So, no, you know, the flow of your code when using control flow mechanism.
It's a very important concept, guys.
And I'm glad that now you know, the general concept as well as how it is being executed and implemented
in C programming language.
I wish you good luck in this section.
And I'll see you in the next video by.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.