1
00:00:00,440 --> 00:00:04,790
In this lecture we will learn about the writing statements.

2
00:00:04,790 --> 00:00:08,300
So a statement can be declared of a variable.

3
00:00:08,450 --> 00:00:14,960
So an expression that evaluates the value or it can definition of a type.

4
00:00:14,960 --> 00:00:21,080
So a statement may also be control structure to affect the flow of the execution throughout your code.

5
00:00:21,680 --> 00:00:24,980
So statements ends with a semicolon here.

6
00:00:25,730 --> 00:00:31,220
Other than that, there are few rules about how to format statements so you can even use a semicolon

7
00:00:31,220 --> 00:00:32,180
on its own.

8
00:00:32,360 --> 00:00:34,760
And this is called a null statement.

9
00:00:34,760 --> 00:00:39,680
So a null statement does nothing here, as you can see here.

10
00:00:39,680 --> 00:00:44,210
So having too many semicolons is usually banning.

11
00:00:44,210 --> 00:00:47,540
So let's write an expression, a simple expression for it.

12
00:00:47,540 --> 00:00:56,510
So an expression is a sequence of operators and operands variable or literals so that result in some

13
00:00:56,510 --> 00:00:57,200
value.

14
00:00:57,200 --> 00:01:00,990
So for example, let's write some statements here.

15
00:01:00,990 --> 00:01:05,400
For example, integer E semicolon, we created an integer.

16
00:01:06,360 --> 00:01:11,760
Integer type variable and let's E equals six.

17
00:01:11,910 --> 00:01:13,920
Multiply by seven.

18
00:01:16,520 --> 00:01:22,790
And answer is this is the comment answer is 69.

19
00:01:22,790 --> 00:01:23,330
No.

20
00:01:23,900 --> 00:01:24,890
42.

21
00:01:26,160 --> 00:01:31,260
So here on the right side, this is an expression.

22
00:01:31,500 --> 00:01:38,940
And the assignment here, this is the assignment from E to the left side to the semicolon on the right

23
00:01:39,090 --> 00:01:40,020
is a statement.

24
00:01:40,020 --> 00:01:46,380
So every expression is either a value or an R value.

25
00:01:46,380 --> 00:01:51,120
So you are most likely to see these keywords used in error descriptions.

26
00:01:51,120 --> 00:02:01,230
So in effect, the the l value is an expression that refers to some memory location.

27
00:02:01,230 --> 00:02:09,990
So items on the left side, items on the left hand side of an assignment must be l values.

28
00:02:09,990 --> 00:02:16,050
So however an l value can appear on the left or right hand side of an assignment.

29
00:02:16,050 --> 00:02:20,010
So all variables are L values.

30
00:02:20,130 --> 00:02:31,750
So an r value here r value is a temporary item that does not exist longer than the expression that uses

31
00:02:31,750 --> 00:02:36,430
it, so it will have a value but cannot have a value assigned to it.

32
00:02:36,610 --> 00:02:41,290
So it can only exist on the right hand side of an assignment.

33
00:02:41,290 --> 00:02:44,380
So literals are R values.

34
00:02:44,380 --> 00:02:46,420
So for example, literals.

35
00:02:46,450 --> 00:02:50,320
Literals are values.

36
00:02:51,250 --> 00:02:52,120
So.

37
00:02:53,960 --> 00:02:56,450
So let's let's go right here.

38
00:02:56,450 --> 00:03:04,100
As you can see, this is the this is the clearest example of the R values and L values here.

39
00:03:04,100 --> 00:03:16,910
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

40
00:03:16,910 --> 00:03:22,910
expression six multiplied by seven results in our value.

41
00:03:22,910 --> 00:03:30,800
So for actually let me write in here E is an L value is E is.

42
00:03:32,270 --> 00:03:35,810
Is l value.

43
00:03:38,110 --> 00:03:45,130
And six multiply by seven is our value.

44
00:03:45,990 --> 00:03:50,670
Yeah, this is our value because of it exists in memory only once.

45
00:03:50,670 --> 00:03:51,540
So.

46
00:03:52,270 --> 00:03:55,720
And we are assigning our value to a value here.

47
00:03:56,230 --> 00:03:56,980
So.

48
00:03:59,920 --> 00:04:03,490
This is an R value here, as you can see here.

49
00:04:03,970 --> 00:04:09,970
But if we So actually, let me print this function here.

50
00:04:09,970 --> 00:04:14,140
Print F actually, let's use C out here.

51
00:04:14,170 --> 00:04:16,330
C out STD.

52
00:04:16,870 --> 00:04:18,070
C out.

53
00:04:19,220 --> 00:04:20,000
Uh, here.

54
00:04:20,720 --> 00:04:22,370
It's, uh, stick out.

55
00:04:23,180 --> 00:04:26,120
Uh, e and end line.

56
00:04:26,540 --> 00:04:28,070
And end line.

57
00:04:29,210 --> 00:04:30,550
Posted online.

58
00:04:32,320 --> 00:04:32,590
Here.

59
00:04:32,590 --> 00:04:33,790
Let's compile this.

60
00:04:33,940 --> 00:04:39,650
And as you can see here, we got the 42 value.

61
00:04:39,670 --> 00:04:42,370
So we return the 42 as a value.

62
00:04:42,370 --> 00:04:45,670
So let's try following sample here.

63
00:04:45,820 --> 00:04:52,270
For example, six let's let's first write six multiply by one and then assign it to E.

64
00:04:53,230 --> 00:04:59,080
So six multiply by one is six, multiply by seven and equals E.

65
00:05:00,290 --> 00:05:07,880
And so as you can see here, we got an error because we cannot assign a value to a value here.

66
00:05:07,880 --> 00:05:11,240
So as you can see here, we got an error failed.

67
00:05:11,840 --> 00:05:13,960
Let's see, what is the error?

68
00:05:13,970 --> 00:05:16,700
What is our error, as you can see here?

69
00:05:18,020 --> 00:05:25,400
When we do this, we get an error like value required as left operand of assignment.

70
00:05:25,400 --> 00:05:30,680
So C plus plus compiler tells us why we got an error.

71
00:05:30,680 --> 00:05:33,320
So I'm going to I'm going to comment this.

72
00:05:33,320 --> 00:05:35,960
So we will do more examples about it.

73
00:05:35,960 --> 00:05:41,570
And I don't want to um, get confused by this errors.

74
00:05:41,570 --> 00:05:49,100
So then I'm commenting this line because now it's not a code anymore, it's just a comment.

75
00:05:49,100 --> 00:05:56,810
So when we run this, we got the we our program is working again, so let's copy this and error here.

76
00:05:56,810 --> 00:06:01,130
And we got we right wrote error on the comment side.

77
00:06:01,130 --> 00:06:06,410
So if you want to try this in your computer, you can delete this code and.

78
00:06:07,610 --> 00:06:07,940
Actually.

79
00:06:07,940 --> 00:06:13,550
So you can delete this code and run this program and compile.

80
00:06:13,580 --> 00:06:20,360
As you can see here, we got the same error value required as left operand of assignment.

81
00:06:20,720 --> 00:06:25,700
So I hope I hope this is pretty understandable here.

82
00:06:26,570 --> 00:06:34,090
So broadly speaking, an expression becomes a statement by when you append a semicolon.

83
00:06:34,100 --> 00:06:49,370
So for example, let's try the following example 42 just on 42 and the semicolon and std sqrt here to.

84
00:06:51,260 --> 00:06:57,170
As you can see here, we need to add add our import function.

85
00:06:57,800 --> 00:06:59,060
As you can see here.

86
00:06:59,700 --> 00:07:01,350
Seemed complex and varied.

87
00:07:01,380 --> 00:07:03,080
So I think it's a a math.

88
00:07:03,090 --> 00:07:04,080
As you can see here.

89
00:07:04,080 --> 00:07:08,550
We added our math library into our C program.

90
00:07:08,550 --> 00:07:16,890
And when we run this application, it it has the same output because we didn't we didn't print anything

91
00:07:16,920 --> 00:07:17,940
on the screen.

92
00:07:17,940 --> 00:07:24,870
So as you can see, we got just an only print function here that prints E and nothing else.

93
00:07:25,200 --> 00:07:27,480
So this is the.

94
00:07:28,540 --> 00:07:29,980
The first line is here.

95
00:07:30,010 --> 00:07:36,850
The first line is an R value of 42, but since it is temporary, it has no effect.

96
00:07:36,850 --> 00:07:40,900
So a cplusplus compiler will optimize it away.

97
00:07:40,900 --> 00:07:43,540
So the second line here, as you can see here.

98
00:07:43,570 --> 00:07:50,380
The second line calls the standard library function to calculate the square root of two.

99
00:07:50,410 --> 00:07:52,270
Actually, let me write it here.

100
00:07:54,160 --> 00:07:55,570
Root of two.

101
00:07:55,750 --> 00:08:00,820
So again, the result is an R value and the value is not used.

102
00:08:00,820 --> 00:08:04,060
So the compiler will optimize this away.

103
00:08:04,570 --> 00:08:10,900
However, it illustrates that the function can be called without using its return value.

104
00:08:10,930 --> 00:08:19,720
Although it is not the case with the STD squared here, so many functions have a lasting effect other

105
00:08:19,720 --> 00:08:20,950
than the return value.

106
00:08:20,950 --> 00:08:29,140
Indeed, the whole point of a function is usually to do something and return value is often used merely

107
00:08:29,140 --> 00:08:31,740
to indicate if the function was successful.

108
00:08:31,750 --> 00:08:39,520
So often, often developers assume that a function will succeed and ignore the return value.

109
00:08:40,440 --> 00:08:45,480
Actually here we got to learn about values and our values.

110
00:08:45,690 --> 00:08:53,640
So you can test these statements and codes in your own computer, actually.

111
00:08:54,240 --> 00:08:56,820
So that's it.

112
00:08:57,130 --> 00:08:57,960
That's this lecture.

113
00:08:57,960 --> 00:09:00,420
And in the next lecture, we're going to learn the comma.

114
00:09:00,570 --> 00:09:04,110
Operator So I'm waiting you in the next lecture.
