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