Hello and welcome back to the next video of this course in programming cities.
Now in this video we will learn about the control statements in case of Cartland.
Now there are some changes in Gears of control statements in case of Cartland such as we can use the
if else condition as an expression an insert of switch statement.
We have re-instatement in case of Cartland.
So let us first check out the if else conditional statements in case of Cartland.
Now here I have simply defined two values equal to do and be equal to 5.
Now here I will simply define a valid max value.
Let's see in.
And now down the side.
I was simply write.
Typical if else condition if it is greater than B then simply assign max value equal to a right and
then is max value equal to B and then finally we are simply going to print the max value right.
Let us note in the chord.
So here in the outbuild we get 5 so we have simply written code to find the maximum value of these two
numbers and B right now in Cartland we have.
If expressions.
Now we can use the if condition as an expression.
So how to do that.
So in that case instead of defining the max value here what we do is simply assign it to the max value
directly.
And here I will simply remove it.
The max value and now leads straight to clean up our record.
So here what I am doing is this.
If as an expression.
Now if it is greater than B then simply return a and assign it to the max value variable is simply returned
B which is the maximum value and assign it to this very bill and at the end.
Simply put into value.
Let us note in the chord so in the output again we get 5 so in Scotland we can make the if condition
to return some value.
Now suppose if I have the multiple lines of code inside the if condition so which value will be returned
and stored to the max value variable.
Now suppose I have a quarter block.
So here what do I have is.
I am having the cord block if condition here and inspired here.
Now I suppose if I have multiple lines of code here let's see.
Print is greater and simply copy the word from here and pasted here and here.
Simply put in B is greater right.
So in this situation where we have multiple lines of code within the if block and also as log.
So which of the following will we return.
Now as for the rule.
The last statement that is defined inside the if condition will be returned.
So here the last part is a and here the last piece of cord is B.
So here it will be returned and here B will be returned.
So this code will be executed and then it will be returned.
And similarly this code will be executed and then B will be returned.
And now let us run the code.
So here we get B is greater and at last we are printing the value of max value variable right.
So in this way we are actually using the condition as the expression.
Now this if condition is returning some value.
So that is why we call it if as expression.