1 00:00:00,810 --> 00:00:01,620 Hello. 2 00:00:01,800 --> 00:00:03,270 Welcome to this lecture. 3 00:00:03,270 --> 00:00:06,520 In this lecture, we're going to learn about the logical operators here. 4 00:00:06,540 --> 00:00:11,490 So these are the logical operators, which I will explain and you will learn in this lecture. 5 00:00:11,490 --> 00:00:17,520 So the logical operators evaluate Boolean logic on bool types. 6 00:00:17,520 --> 00:00:21,900 So you characterize operators by how many operands they take. 7 00:00:21,900 --> 00:00:29,430 So a unary operator here takes a single parent, and a binary operator takes two. 8 00:00:29,520 --> 00:00:32,280 A ternary operator takes three and so on. 9 00:00:32,280 --> 00:00:37,770 So you can categorize operators further by describing the types of their operands. 10 00:00:37,770 --> 00:00:48,990 So the unary negation operator here, this not operator takes a single operand and returns its opposite. 11 00:00:49,860 --> 00:00:52,700 In other words, a urinary. 12 00:00:52,710 --> 00:00:58,950 Here, let me write text this here if you write like. 13 00:01:00,920 --> 00:01:03,470 Your honorary crew. 14 00:01:04,610 --> 00:01:05,660 You know true. 15 00:01:05,690 --> 00:01:09,880 You will get the false here. 16 00:01:11,540 --> 00:01:11,990 Here. 17 00:01:11,990 --> 00:01:13,550 Let me actually. 18 00:01:18,930 --> 00:01:19,650 Okay. 19 00:01:23,030 --> 00:01:24,980 Not operator. 20 00:01:26,280 --> 00:01:26,730 Here. 21 00:01:27,800 --> 00:01:31,340 And make it left all the way. 22 00:01:33,700 --> 00:01:43,360 So this you will if you put the true in this in this operand, you will get the false or bitwise here. 23 00:01:43,360 --> 00:01:46,480 If you give the false, you will get true. 24 00:01:46,510 --> 00:01:52,390 So this takes only one apparent and not apparent takes only one operation. 25 00:01:52,390 --> 00:01:55,480 So and the other negotiation. 26 00:01:55,480 --> 00:02:07,000 This is the union negotiation operator here but the logical operators, for example, and plus and or 27 00:02:07,000 --> 00:02:18,100 operator here this is or so this is and and this is or so the logical end returns true only if both 28 00:02:18,100 --> 00:02:20,380 of its operands are true. 29 00:02:20,380 --> 00:02:22,960 So if, for example. 30 00:02:23,500 --> 00:02:23,900 Um. 31 00:02:25,630 --> 00:02:26,350 True. 32 00:02:27,880 --> 00:02:32,230 True and true, then this equals to true. 33 00:02:32,530 --> 00:02:38,710 But if you give this apparent the true and false true. 34 00:02:40,040 --> 00:02:43,400 And false, you will get the files. 35 00:02:43,400 --> 00:02:51,290 So actually, it might be complicated here, but I promise you will learn all about this options here. 36 00:02:51,290 --> 00:02:52,790 So at first. 37 00:02:53,480 --> 00:02:54,940 Yeah, it will. 38 00:02:54,940 --> 00:02:56,650 You still see this? 39 00:02:56,810 --> 00:02:57,250 Appearance? 40 00:02:57,250 --> 00:03:00,460 Complicated, but it's not that complicated at all. 41 00:03:00,460 --> 00:03:01,570 So. 42 00:03:02,970 --> 00:03:05,550 Let's make the OR operator here. 43 00:03:05,550 --> 00:03:07,380 So this is the OR operator. 44 00:03:08,310 --> 00:03:09,270 So if you. 45 00:03:11,430 --> 00:03:16,350 All logical or here logical or if you give the true. 46 00:03:17,050 --> 00:03:22,600 If either of the both of its operands are true, then it returns true, for example. 47 00:03:22,720 --> 00:03:34,480 So if for for example, I have false and true, this will get or let's make it more understandable if 48 00:03:34,480 --> 00:03:38,830 I have true and true or false and false, it doesn't matter. 49 00:03:38,830 --> 00:03:39,310 Here. 50 00:03:39,610 --> 00:03:42,880 It's appearance false. 51 00:03:43,210 --> 00:03:45,190 You will get true. 52 00:03:46,670 --> 00:03:47,210 Now. 53 00:03:50,090 --> 00:03:51,230 You will get false. 54 00:03:51,470 --> 00:03:55,520 But if you give true and. 55 00:03:56,820 --> 00:03:59,250 Pulse, you will get false two. 56 00:03:59,610 --> 00:04:00,540 You will get true. 57 00:04:00,960 --> 00:04:02,040 Sorry for this. 58 00:04:02,040 --> 00:04:05,970 So if you have just one true, you will get the true here. 59 00:04:05,970 --> 00:04:13,410 But if you have to false which is zero, you will get the false with this operator. 60 00:04:13,560 --> 00:04:20,330 So logical operators might seem confusing at first, but they quickly become intuitive. 61 00:04:20,340 --> 00:04:24,420 So let's open our Visual Studio code here. 62 00:04:26,330 --> 00:04:29,240 This is our Visual Studio code. 63 00:04:30,390 --> 00:04:30,990 Okay. 64 00:04:31,890 --> 00:04:33,900 So this is our Visual Studio code. 65 00:04:34,080 --> 00:04:36,750 Let's delete the previous lectures. 66 00:04:43,500 --> 00:04:43,950 Here. 67 00:04:44,950 --> 00:04:51,250 This is all the lectures which you can download these codes in the downloadable sections of this Udemy 68 00:04:51,250 --> 00:04:52,540 course Oxley. 69 00:04:53,050 --> 00:04:55,210 So let's create some. 70 00:04:55,950 --> 00:04:56,610 Courtier. 71 00:05:02,870 --> 00:05:09,180 Okay, so let's create, for example, bool, bool. 72 00:05:09,200 --> 00:05:10,160 So this is the bool. 73 00:05:10,160 --> 00:05:14,780 As you know, in previous lectures we learned about the bull type. 74 00:05:15,890 --> 00:05:19,880 For example, True equals true. 75 00:05:21,600 --> 00:05:25,080 Bull f with this means false. 76 00:05:25,110 --> 00:05:27,450 Equals false here. 77 00:05:27,450 --> 00:05:32,330 And let's create our illustrations with our common line here. 78 00:05:32,340 --> 00:05:34,560 And so printf. 79 00:05:34,590 --> 00:05:35,700 Printf. 80 00:05:37,080 --> 00:05:38,130 Let's start. 81 00:05:38,490 --> 00:05:41,530 Let's start with, um. 82 00:05:44,330 --> 00:05:47,420 Let's start with the not operator here. 83 00:05:48,920 --> 00:05:49,140 Uh. 84 00:05:49,190 --> 00:05:49,910 Okay. 85 00:05:54,360 --> 00:05:57,660 So let's start with note, Operator. 86 00:05:58,200 --> 00:06:00,480 We will illustrate in code. 87 00:06:01,170 --> 00:06:01,980 True. 88 00:06:03,340 --> 00:06:06,280 The and new line. 89 00:06:07,990 --> 00:06:18,250 Here a new line and gave this the let's give this the real operator here. 90 00:06:19,000 --> 00:06:19,600 True. 91 00:06:20,710 --> 00:06:29,930 As you can see here, we gave the we use this ternary this not operator and we operated this true. 92 00:06:30,310 --> 00:06:37,090 So after after this, you will see what it will give to us and then print f. 93 00:06:37,990 --> 00:06:39,840 So let me mention here. 94 00:06:39,850 --> 00:06:44,740 The one is true and the zero is false. 95 00:06:47,310 --> 00:06:51,300 This is the pretty common information here. 96 00:06:51,300 --> 00:06:55,910 The one is true and zero is false, but some of you might not know about this. 97 00:06:55,920 --> 00:07:07,710 So in case I wrote this down here and let's continue on the next line here, the true and. 98 00:07:09,260 --> 00:07:11,240 Through true and false. 99 00:07:13,080 --> 00:07:13,770 Uh, the. 100 00:07:15,180 --> 00:07:16,380 A new line. 101 00:07:17,230 --> 00:07:18,370 Let's see. 102 00:07:19,740 --> 00:07:20,820 Um, t. 103 00:07:22,630 --> 00:07:24,160 And false. 104 00:07:25,240 --> 00:07:27,430 T and false. 105 00:07:28,350 --> 00:07:37,350 And let's continue with as I always do, I will explain all of these codes later when we extract and 106 00:07:37,350 --> 00:07:38,550 run these codes. 107 00:07:38,550 --> 00:07:40,170 So print F. 108 00:07:42,040 --> 00:07:42,820 True. 109 00:07:43,330 --> 00:07:45,790 And here we will. 110 00:07:48,000 --> 00:07:48,750 Printf. 111 00:07:48,780 --> 00:07:49,500 True. 112 00:07:50,500 --> 00:07:56,680 Here, we will see the true and. 113 00:07:57,420 --> 00:07:58,710 Not false. 114 00:08:00,120 --> 00:08:01,740 And let's create the here. 115 00:08:02,590 --> 00:08:03,370 That's all. 116 00:08:04,750 --> 00:08:09,580 Which will give us the 0 or 1 in case it's zero. 117 00:08:09,610 --> 00:08:12,250 It will give us the zero. 118 00:08:12,640 --> 00:08:14,020 It will give us the false. 119 00:08:14,020 --> 00:08:22,510 But in case it's the one, which is it will the compiler will show us the one here. 120 00:08:22,510 --> 00:08:23,080 So. 121 00:08:24,670 --> 00:08:27,490 Then let's give this the. 122 00:08:29,490 --> 00:08:30,270 True. 123 00:08:31,360 --> 00:08:32,080 And. 124 00:08:33,140 --> 00:08:34,820 True and not false. 125 00:08:35,180 --> 00:08:36,290 Not false. 126 00:08:37,570 --> 00:08:38,800 Not f here. 127 00:08:39,220 --> 00:08:41,970 And let's add another line of code here. 128 00:08:41,980 --> 00:08:42,970 Print f. 129 00:08:44,910 --> 00:08:47,520 True or true. 130 00:08:47,730 --> 00:08:48,960 True or false? 131 00:08:51,270 --> 00:08:52,770 True or false? 132 00:08:55,660 --> 00:08:56,290 Here. 133 00:08:57,880 --> 00:08:58,280 Ops. 134 00:09:00,790 --> 00:09:01,480 Here. 135 00:09:01,780 --> 00:09:04,030 Well, actually, it's okay. 136 00:09:07,420 --> 00:09:11,740 True or false and gave this true. 137 00:09:12,680 --> 00:09:14,060 Interpreters here. 138 00:09:14,090 --> 00:09:14,900 Pulse. 139 00:09:16,310 --> 00:09:17,390 Uh, f here. 140 00:09:17,960 --> 00:09:26,630 So, as you know, here we have a boolean variable which named T is true, and boolean variable named 141 00:09:26,960 --> 00:09:28,970 F is false. 142 00:09:29,450 --> 00:09:32,750 Here and print F plus. 143 00:09:32,750 --> 00:09:40,190 This is the last line of code which after this you will know about and I will explain the all of these 144 00:09:40,570 --> 00:09:45,170 code lines later, line by line and false. 145 00:09:46,430 --> 00:09:47,270 Or operator? 146 00:09:47,270 --> 00:09:48,050 False. 147 00:09:52,120 --> 00:09:53,350 Falls here. 148 00:09:53,770 --> 00:09:59,470 And the new line here, we will get the F. 149 00:09:59,980 --> 00:10:01,300 F here. 150 00:10:02,420 --> 00:10:09,110 Lastly and then let's save our code and run our program. 151 00:10:09,360 --> 00:10:13,310 CMD Where was our program? 152 00:10:13,310 --> 00:10:15,380 Here, let me find it. 153 00:10:16,900 --> 00:10:18,120 Okay, dear. 154 00:10:19,750 --> 00:10:21,190 See desktop. 155 00:10:21,880 --> 00:10:25,660 Dear here three desktop dear. 156 00:10:26,960 --> 00:10:29,680 Okay, so let's compile our application here. 157 00:10:29,690 --> 00:10:36,040 GCC color so GCC or clear. 158 00:10:36,050 --> 00:10:46,220 Firstly, GCC main dot main.cpp here our code is compiled without an error. 159 00:10:46,460 --> 00:10:50,420 And then let's run this program. 160 00:10:51,450 --> 00:10:53,020 A dot x here. 161 00:10:53,040 --> 00:10:58,100 So as you can see here, we have these codes. 162 00:10:58,110 --> 00:11:01,530 So let's copy this codes here. 163 00:11:01,770 --> 00:11:02,160 Oops. 164 00:11:06,560 --> 00:11:07,190 Here. 165 00:11:13,310 --> 00:11:22,290 And copy and paste these codes in our diagram to explain it more. 166 00:11:22,310 --> 00:11:22,880 Here. 167 00:11:24,650 --> 00:11:25,080 Oops. 168 00:11:25,540 --> 00:11:26,460 What the. 169 00:11:27,030 --> 00:11:27,590 Okay. 170 00:11:29,960 --> 00:11:31,970 Actually we can do this in. 171 00:11:32,930 --> 00:11:33,440 Right. 172 00:11:35,260 --> 00:11:35,830 So. 173 00:11:38,270 --> 00:11:42,230 Let's explain these codes one by one. 174 00:11:43,180 --> 00:11:50,440 Here the at the first you see the negotiation operator. 175 00:11:51,250 --> 00:11:52,390 Which is false. 176 00:11:53,040 --> 00:11:57,900 So if true is not true, then it's false. 177 00:11:57,900 --> 00:12:01,640 So it gave us the zero, which is false. 178 00:12:01,650 --> 00:12:03,990 And the second here. 179 00:12:04,560 --> 00:12:05,310 Second. 180 00:12:06,760 --> 00:12:07,390 True. 181 00:12:07,390 --> 00:12:08,110 Not true. 182 00:12:08,140 --> 00:12:09,040 Operator. 183 00:12:11,360 --> 00:12:12,020 Here. 184 00:12:13,440 --> 00:12:14,550 Or not true. 185 00:12:14,580 --> 00:12:15,150 True and. 186 00:12:15,150 --> 00:12:16,560 And false Here. 187 00:12:17,610 --> 00:12:19,560 If true. 188 00:12:19,560 --> 00:12:21,300 And then false. 189 00:12:22,240 --> 00:12:31,000 Uh, as I said, uh, if you use true in order in order to you, if you have to get true from this end. 190 00:12:31,030 --> 00:12:40,190 Operator, you need to give the twice to true operators in this operand here. 191 00:12:40,210 --> 00:12:48,130 So as you shown here, we get we got the zero from this operation. 192 00:12:48,130 --> 00:12:53,430 And then true and not false. 193 00:12:53,440 --> 00:12:57,760 So if it's not false, we will get the true true or false. 194 00:12:57,760 --> 00:13:04,200 We will get the one, as I explained in this lecture at the beginning. 195 00:13:04,210 --> 00:13:09,430 And if false or false, it will give give us a zero. 196 00:13:09,430 --> 00:13:20,710 Because in order to work with get one from or operator, we need at least one. 197 00:13:20,710 --> 00:13:23,360 True in our operation. 198 00:13:25,210 --> 00:13:32,080 So I'm waiting you in the next lecture, which in the next lecture we will learn the new type here. 199 00:13:32,260 --> 00:13:34,180 Standard by type. 200 00:13:34,180 --> 00:13:36,610 So I'm waiting you in the next lecture.