In this lecture we will learn about the writing statements.
So a statement can be declared of a variable.
So an expression that evaluates the value or it can definition of a type.
So a statement may also be control structure to affect the flow of the execution throughout your code.
So statements ends with a semicolon here.
Other than that, there are few rules about how to format statements so you can even use a semicolon
on its own.
And this is called a null statement.
So a null statement does nothing here, as you can see here.
So having too many semicolons is usually banning.
So let's write an expression, a simple expression for it.
So an expression is a sequence of operators and operands variable or literals so that result in some
value.
So for example, let's write some statements here.
For example, integer E semicolon, we created an integer.
Integer type variable and let's E equals six.
Multiply by seven.
And answer is this is the comment answer is 69.
No.
42.
So here on the right side, this is an expression.
And the assignment here, this is the assignment from E to the left side to the semicolon on the right
is a statement.
So every expression is either a value or an R value.
So you are most likely to see these keywords used in error descriptions.
So in effect, the the l value is an expression that refers to some memory location.
So items on the left side, items on the left hand side of an assignment must be l values.
So however an l value can appear on the left or right hand side of an assignment.
So all variables are L values.
So an r value here r value is a temporary item that does not exist longer than the expression that uses
it, so it will have a value but cannot have a value assigned to it.
So it can only exist on the right hand side of an assignment.
So literals are R values.
So for example, literals.
Literals are values.
So.
So let's let's go right here.
As you can see, this is the this is the clearest example of the R values and L values here.
So as you can see here in the this in second line in the 10th line in this line here is an L value and
expression six multiplied by seven results in our value.
So for actually let me write in here E is an L value is E is.
Is l value.
And six multiply by seven is our value.
Yeah, this is our value because of it exists in memory only once.
So.
And we are assigning our value to a value here.
So.
This is an R value here, as you can see here.
But if we So actually, let me print this function here.
Print F actually, let's use C out here.
C out STD.
C out.
Uh, here.
It's, uh, stick out.
Uh, e and end line.
And end line.
Posted online.
Here.
Let's compile this.
And as you can see here, we got the 42 value.
So we return the 42 as a value.
So let's try following sample here.
For example, six let's let's first write six multiply by one and then assign it to E.
So six multiply by one is six, multiply by seven and equals E.
And so as you can see here, we got an error because we cannot assign a value to a value here.
So as you can see here, we got an error failed.
Let's see, what is the error?
What is our error, as you can see here?
When we do this, we get an error like value required as left operand of assignment.
So C plus plus compiler tells us why we got an error.
So I'm going to I'm going to comment this.
So we will do more examples about it.
And I don't want to um, get confused by this errors.
So then I'm commenting this line because now it's not a code anymore, it's just a comment.
So when we run this, we got the we our program is working again, so let's copy this and error here.
And we got we right wrote error on the comment side.
So if you want to try this in your computer, you can delete this code and.
Actually.
So you can delete this code and run this program and compile.
As you can see here, we got the same error value required as left operand of assignment.
So I hope I hope this is pretty understandable here.
So broadly speaking, an expression becomes a statement by when you append a semicolon.
So for example, let's try the following example 42 just on 42 and the semicolon and std sqrt here to.
As you can see here, we need to add add our import function.
As you can see here.
Seemed complex and varied.
So I think it's a a math.
As you can see here.
We added our math library into our C program.
And when we run this application, it it has the same output because we didn't we didn't print anything
on the screen.
So as you can see, we got just an only print function here that prints E and nothing else.
So this is the.
The first line is here.
The first line is an R value of 42, but since it is temporary, it has no effect.
So a cplusplus compiler will optimize it away.
So the second line here, as you can see here.
The second line calls the standard library function to calculate the square root of two.
Actually, let me write it here.
Root of two.
So again, the result is an R value and the value is not used.
So the compiler will optimize this away.
However, it illustrates that the function can be called without using its return value.
Although it is not the case with the STD squared here, so many functions have a lasting effect other
than the return value.
Indeed, the whole point of a function is usually to do something and return value is often used merely
to indicate if the function was successful.
So often, often developers assume that a function will succeed and ignore the return value.
Actually here we got to learn about values and our values.
So you can test these statements and codes in your own computer, actually.
So that's it.
That's this lecture.
And in the next lecture, we're going to learn the comma.
Operator So I'm waiting you in the next lecture.