1 00:00:02,000 --> 00:00:02,520 Hello. 2 00:00:02,540 --> 00:00:08,840 In this lecture, you will learn about the C++ writing techniques and language features. 3 00:00:09,890 --> 00:00:16,760 So C++ is a very flexible language when it comes to formatting and writing code. 4 00:00:17,000 --> 00:00:20,360 So it's also a strong type language. 5 00:00:20,360 --> 00:00:26,720 So meaning that there are rules about declaring the types of variables which you can use to your advantage 6 00:00:26,720 --> 00:00:30,290 by making the compiler help you write better code. 7 00:00:30,320 --> 00:00:33,660 In the section we will cover. 8 00:00:33,680 --> 00:00:39,170 Have the format, C++ code and rules on declaring and scoping variables. 9 00:00:39,800 --> 00:00:43,220 In this lecture, we are going to start with the white spaces. 10 00:00:43,520 --> 00:00:46,130 How you can use white spaces in C++. 11 00:00:46,250 --> 00:00:56,030 So here, other than string literals in white spaces you have free usage of white spaces. 12 00:00:56,030 --> 00:01:07,640 So you can, as long as as many as you can use, as many as tabs, spaces, spaces, spaces and new 13 00:01:07,640 --> 00:01:08,280 lines. 14 00:01:08,330 --> 00:01:08,930 New lines. 15 00:01:08,930 --> 00:01:12,320 As you can see, you won't, you will. 16 00:01:12,350 --> 00:01:15,110 You will not get any error because of it. 17 00:01:15,530 --> 00:01:22,580 As you can see, you can use as long as many as new lines, tabs and spaces you want here. 18 00:01:24,960 --> 00:01:25,560 As you can see. 19 00:01:25,560 --> 00:01:26,640 Let's compile it. 20 00:01:26,670 --> 00:01:31,920 As you can see, C++ compiler doesn't care about them, so. 21 00:01:34,730 --> 00:01:40,280 But C++ statements are eliminated by semicolons here, as you can see here. 22 00:01:40,760 --> 00:01:44,730 So let's create an example code so as to explain it better. 23 00:01:44,750 --> 00:01:47,300 So for example, let's build an integer variable. 24 00:01:47,960 --> 00:01:54,030 Assign four and integer equals integer divide by two. 25 00:01:54,050 --> 00:01:56,120 So we will get two from it. 26 00:01:56,240 --> 00:01:59,960 And let's print a print of this. 27 00:02:00,260 --> 00:02:06,860 As you can see here, we get we got an error because in print. 28 00:02:07,130 --> 00:02:09,680 So we have to use the print. 29 00:02:09,800 --> 00:02:12,660 We have to use inclusive library. 30 00:02:13,250 --> 00:02:17,990 You will learn about how to include library and what library is in later lectures. 31 00:02:18,680 --> 00:02:21,530 But it's not our thing to learn. 32 00:02:21,530 --> 00:02:22,940 But you will learn in next. 33 00:02:22,940 --> 00:02:29,540 Lectures include here std that h here. 34 00:02:29,570 --> 00:02:32,660 As you can see, we got rid of this error. 35 00:02:32,840 --> 00:02:34,060 Here return. 36 00:02:34,920 --> 00:02:36,530 Let's return zero from it. 37 00:02:36,530 --> 00:02:37,310 Integer function. 38 00:02:37,550 --> 00:02:39,950 As you can see here, this function returns zero. 39 00:02:39,980 --> 00:02:40,940 You will learn. 40 00:02:41,660 --> 00:02:47,690 And then here, as you can see if we got the format then. 41 00:02:48,760 --> 00:02:50,680 And let's bring something on it. 42 00:02:50,770 --> 00:03:00,280 So as you can see, if you if you read the latest statement this, we will get an error, as you can 43 00:03:00,280 --> 00:03:01,060 see here. 44 00:03:02,400 --> 00:03:03,180 And the. 45 00:03:04,000 --> 00:03:04,450 Yeah. 46 00:03:04,840 --> 00:03:12,130 Let's include our statement here and delete this common line. 47 00:03:12,250 --> 00:03:12,970 Clear. 48 00:03:12,970 --> 00:03:16,540 And yeah, so let's print this values on it. 49 00:03:16,540 --> 00:03:21,310 Actually, let's, let's use the C out. 50 00:03:22,510 --> 00:03:23,850 We will use a. 51 00:03:25,570 --> 00:03:25,900 We will. 52 00:03:25,990 --> 00:03:29,350 We will use the print of later in this course. 53 00:03:29,470 --> 00:03:31,780 So as you can see, we're going to error from it. 54 00:03:31,810 --> 00:03:33,190 Let me write this code. 55 00:03:33,850 --> 00:03:39,160 The result result is we will pass e. 56 00:03:39,190 --> 00:03:44,920 As you can see, we will pass E and then end line here and line. 57 00:03:46,050 --> 00:03:48,030 So as you can see, we've got an error. 58 00:03:48,660 --> 00:03:52,410 So if you include the stream. 59 00:03:54,090 --> 00:03:56,850 You will get rid of that error. 60 00:03:57,420 --> 00:04:03,510 That's because the STD library needs input output stream here. 61 00:04:03,510 --> 00:04:04,080 So. 62 00:04:05,140 --> 00:04:11,000 And and as you can see, if we delete the print a function so we are not using print to function anymore. 63 00:04:11,690 --> 00:04:13,850 We don't need this library. 64 00:04:13,850 --> 00:04:22,310 And as you can see here, see lion ID this blue or just the great gray color, this text for it. 65 00:04:22,790 --> 00:04:25,100 And then here. 66 00:04:26,460 --> 00:04:29,460 As you can see here, we have a new line here. 67 00:04:31,600 --> 00:04:32,230 Ever. 68 00:04:32,260 --> 00:04:36,520 Between a rope line and let's run and compile our program and we got an. 69 00:04:36,970 --> 00:04:40,330 Result here the result is two. 70 00:04:41,170 --> 00:04:43,390 So let's try one example here. 71 00:04:43,420 --> 00:04:45,160 Just let these new lines. 72 00:04:46,840 --> 00:04:47,440 Yes. 73 00:04:47,590 --> 00:04:49,690 Just in these new lines. 74 00:04:50,350 --> 00:04:54,430 And let's write if this works here or this. 75 00:04:55,620 --> 00:04:56,160 Yeah. 76 00:04:57,120 --> 00:04:57,380 Officer. 77 00:04:57,540 --> 00:05:01,510 We need these two semicolons and we do this too. 78 00:05:01,530 --> 00:05:08,460 So you can't put the spaces on new lines between variable names or functions or whatever you want here 79 00:05:08,460 --> 00:05:12,150 and you can use here. 80 00:05:12,180 --> 00:05:15,670 As you can see, we got the same result. 81 00:05:15,690 --> 00:05:18,660 So there are some cases white spaces is needed. 82 00:05:18,660 --> 00:05:23,640 For example, when declaring a variable, you must have a whitespace between the type and the variable 83 00:05:23,640 --> 00:05:24,090 name. 84 00:05:24,840 --> 00:05:29,790 So, but the convention is to be judicious as possible to make the code readable. 85 00:05:29,790 --> 00:05:37,140 And while it's perfectly correct language wise to put all the statements in one line like a JavaScript, 86 00:05:37,140 --> 00:05:42,000 but it makes the code almost completely unreadable. 87 00:05:42,120 --> 00:05:48,450 So of course it's less unreadable than the previous previous code here, as you can see. 88 00:05:48,450 --> 00:05:50,910 Here, let me here. 89 00:05:51,210 --> 00:05:52,620 This is more readable, right? 90 00:05:52,740 --> 00:05:53,910 So actually, it's. 91 00:05:56,660 --> 00:05:58,890 That's correct. 92 00:05:58,910 --> 00:06:07,310 Let's notice this, because I'm uploading this files to every lectures and you can download and use 93 00:06:07,310 --> 00:06:09,370 this codes by letter. 94 00:06:09,380 --> 00:06:21,650 So for example, correct by language wise, but are readable and readable and readable. 95 00:06:22,640 --> 00:06:25,940 And let's collec let's write another code here. 96 00:06:26,240 --> 00:06:26,780 For example. 97 00:06:26,780 --> 00:06:27,140 Let's. 98 00:06:27,410 --> 00:06:32,690 So as soon as you know, we can create a two variables at the same name. 99 00:06:32,690 --> 00:06:35,570 So I'm going to change these names here. 100 00:06:38,040 --> 00:06:38,670 So. 101 00:06:39,740 --> 00:06:46,700 Of course you can print the E as long as you want, but you just can create the same name. 102 00:06:47,330 --> 00:06:48,410 Same name variable. 103 00:06:48,440 --> 00:06:49,670 Same name Variable. 104 00:06:49,670 --> 00:06:53,900 So as you can see here, this is here. 105 00:06:56,000 --> 00:06:56,270 Yeah. 106 00:06:57,650 --> 00:07:00,590 This is correct. 107 00:07:00,860 --> 00:07:01,490 Correct. 108 00:07:01,490 --> 00:07:04,910 By language wise. 109 00:07:06,540 --> 00:07:12,390 All right, Let's just create a program will compile. 110 00:07:13,320 --> 00:07:17,880 Without problem but unreadable. 111 00:07:18,360 --> 00:07:25,570 So I will explain why we need this readable and unreadable codes here now. 112 00:07:25,590 --> 00:07:26,340 So. 113 00:07:27,740 --> 00:07:37,160 Being in mind that if the Court right your right is viable, it may use it may in use for decades, 114 00:07:37,610 --> 00:07:42,200 which means you may have to come back to court the years after you've worked it. 115 00:07:42,200 --> 00:07:46,170 And it means that other people will support your court, too. 116 00:07:46,190 --> 00:07:54,920 So making your code readable is not only courtesy to other developers, but readable code is always 117 00:07:55,160 --> 00:07:57,390 likely targets for replacement. 118 00:07:57,410 --> 00:08:02,240 Here, as you can see here, of course, it's more readable than this. 119 00:08:02,690 --> 00:08:03,350 So. 120 00:08:04,360 --> 00:08:05,320 In this lecture. 121 00:08:05,320 --> 00:08:10,380 In next lecture you will learn about the formatting, the code in C++. 122 00:08:10,390 --> 00:08:12,010 So see you in the next lecture.