1 00:00:02,990 --> 00:00:04,400 In this lecture. 2 00:00:05,540 --> 00:00:09,200 You will learn about the boolean types here. 3 00:00:11,720 --> 00:00:14,810 Boolean types have two states. 4 00:00:15,560 --> 00:00:18,050 True or false? 5 00:00:20,060 --> 00:00:29,090 The sole boolean type is bool, so integer types and the bool types convert readily. 6 00:00:29,360 --> 00:00:32,900 The true state converts to one. 7 00:00:33,200 --> 00:00:40,790 So true equals to one, but the zero so false equals to zero. 8 00:00:43,370 --> 00:00:47,870 Also any non-zero integer converts to one. 9 00:00:49,360 --> 00:01:03,040 And the nonzero one and the zero converts zero to 0 or 0 equals false. 10 00:01:03,430 --> 00:01:05,290 So in integer types here. 11 00:01:05,950 --> 00:01:08,500 Integer to boolean. 12 00:01:08,650 --> 00:01:11,730 So we have a boolean literals here. 13 00:01:11,740 --> 00:01:20,200 So to to initialize boolean types you use to boolean literal either true or false here. 14 00:01:20,980 --> 00:01:30,190 My bool boolean equals you can assign this true or false. 15 00:01:31,870 --> 00:01:32,320 That's. 16 00:01:33,220 --> 00:01:33,640 Here. 17 00:01:33,640 --> 00:01:40,090 So we have a format specifier for Boolean as well as other variables. 18 00:01:40,480 --> 00:01:47,710 The format specifier for boolean is D, there is no format specifiers for boolean actually, but you 19 00:01:47,710 --> 00:01:50,650 can use the integer format specifier. 20 00:01:50,740 --> 00:01:55,960 D within the print f to yield a one. 21 00:01:56,700 --> 00:02:00,030 For true and zero for false. 22 00:02:00,060 --> 00:02:07,980 The reason is that the print f promotes any integral value smaller than an integer to an int. 23 00:02:08,010 --> 00:02:17,700 So here, let's create an R code that illustrates how to declare a boolean variable and inspect its 24 00:02:17,700 --> 00:02:18,450 value. 25 00:02:19,610 --> 00:02:27,380 So so before it, I want to show you some illustrations here, which I got from the Internet, Google 26 00:02:27,380 --> 00:02:28,070 Pictures. 27 00:02:29,060 --> 00:02:39,410 So we have you will learn about the logical and and or tables in later in this lectures actually. 28 00:02:39,410 --> 00:02:43,790 So you will learn about the let me open the separator. 29 00:02:43,790 --> 00:02:47,060 So we we are now learning about the operators. 30 00:02:47,060 --> 00:02:51,620 As you know there is a six operator types in C plus plus. 31 00:02:51,650 --> 00:03:05,090 Now we'll we are learning about the logical operators of C plus plus and which actually you already 32 00:03:05,090 --> 00:03:06,860 know, arithmetic operators. 33 00:03:06,890 --> 00:03:15,260 Now we are learning about the logical operators after that assignment, bitwise, relational operators 34 00:03:15,260 --> 00:03:17,510 and other operators. 35 00:03:17,510 --> 00:03:18,500 So. 36 00:03:19,700 --> 00:03:26,150 And this is the arithmetic relational, logical bitwise, increment decrement and assignment operators. 37 00:03:26,150 --> 00:03:32,420 So now we are learning about the logical operators with Boolean numbers. 38 00:03:32,690 --> 00:03:33,710 So. 39 00:03:35,450 --> 00:03:36,370 Here. 40 00:03:36,380 --> 00:03:40,190 This is the logical operators as well, which you will learn here. 41 00:03:40,190 --> 00:03:45,950 So let's create our code and I will explain all of these details later. 42 00:03:45,950 --> 00:03:48,980 So let's create an BOOL number. 43 00:03:49,010 --> 00:03:51,260 Bool P1 True. 44 00:03:51,530 --> 00:03:56,060 I will explain all of these codes later as I'll as I always do. 45 00:03:56,630 --> 00:03:59,690 Bull B two equals false. 46 00:04:01,050 --> 00:04:03,360 And the print f. 47 00:04:04,310 --> 00:04:04,480 Yeah. 48 00:04:04,490 --> 00:04:05,780 Let's use our own format. 49 00:04:05,780 --> 00:04:14,180 Specifiers d d and new line gave this as variable b1 b2 as you know. 50 00:04:14,180 --> 00:04:20,390 Now this B1 goes to the first format specifier and B2 goes to. 51 00:04:21,790 --> 00:04:24,220 Second former specifier, which you know already. 52 00:04:24,220 --> 00:04:31,000 But I want to wanted to mention it and let's compile it our code. 53 00:04:32,740 --> 00:04:33,160 Here. 54 00:04:36,180 --> 00:04:36,690 Please see. 55 00:04:36,700 --> 00:04:42,940 See Main.cpp here and exit. 56 00:04:44,010 --> 00:04:54,420 The first variables, which is the one, comes through because as I said, if there's a one, if the 57 00:04:54,420 --> 00:04:56,460 integer is one, then this true. 58 00:04:56,460 --> 00:04:59,220 If the boolean is true, then integer is one. 59 00:04:59,400 --> 00:05:03,690 So it showed us the one and b two is false. 60 00:05:03,690 --> 00:05:10,740 Because of that zero it showed us zero and console. 61 00:05:11,940 --> 00:05:19,770 Uh, so in bool with Boolean, it automatically comes to the comparison operators because that's what 62 00:05:19,770 --> 00:05:21,480 Booleans are about, right? 63 00:05:21,570 --> 00:05:27,600 The operators are functions that perform computations on operands. 64 00:05:27,900 --> 00:05:35,280 Operands are simply objects, logical operators you will see in later lectures. 65 00:05:35,280 --> 00:05:43,500 So in order to have a meaningful examples using bool types, you will take a quick look at comparison 66 00:05:43,500 --> 00:05:50,400 operators in this lecture and logical operators in the next so you can use several operators to build 67 00:05:50,400 --> 00:05:51,780 boolean expressions. 68 00:05:52,440 --> 00:05:53,610 The comparisons. 69 00:05:53,820 --> 00:06:01,170 Comparison operators take two arguments and returns a bool so the available operators are equality here. 70 00:06:02,580 --> 00:06:05,700 Equality in equality. 71 00:06:06,060 --> 00:06:16,240 So let me write that down here so I can share it with share with you in our lectures, um, downloadable 72 00:06:16,240 --> 00:06:20,950 sections, so you can download it and use it in your own compiler. 73 00:06:20,950 --> 00:06:22,960 So this is the equality. 74 00:06:24,910 --> 00:06:26,500 Uh, equality. 75 00:06:27,640 --> 00:06:29,830 And this is inequality. 76 00:06:37,350 --> 00:06:38,930 And then here. 77 00:06:39,000 --> 00:06:40,140 Here it comes. 78 00:06:40,140 --> 00:06:43,800 The here it comes. 79 00:06:43,800 --> 00:06:44,970 The greater than. 80 00:06:46,540 --> 00:06:48,550 Then less than. 81 00:06:51,660 --> 00:06:56,340 Less than and greater than. 82 00:06:56,340 --> 00:06:57,630 Or equal to. 83 00:06:57,660 --> 00:06:58,380 Greater than. 84 00:06:58,380 --> 00:07:00,480 Or equal to. 85 00:07:03,590 --> 00:07:04,170 Three. 86 00:07:04,310 --> 00:07:09,860 It's like a math operators write you which you learned in middle school, I think. 87 00:07:09,860 --> 00:07:10,430 Or. 88 00:07:11,950 --> 00:07:18,520 Greater than and less than. 89 00:07:18,870 --> 00:07:20,050 Ops greater. 90 00:07:20,050 --> 00:07:21,310 Not greater than here. 91 00:07:21,490 --> 00:07:23,980 Greater than or equal. 92 00:07:25,210 --> 00:07:30,520 Two and here is less than less than. 93 00:07:31,960 --> 00:07:33,790 Or equal to. 94 00:07:36,720 --> 00:07:37,500 Here. 95 00:07:37,500 --> 00:07:38,280 So. 96 00:07:40,250 --> 00:07:43,250 Let's create an example program about this. 97 00:07:45,740 --> 00:07:46,820 Which year? 98 00:07:48,830 --> 00:07:50,900 Let's print something here. 99 00:07:52,310 --> 00:07:54,650 Seven equal. 100 00:07:54,650 --> 00:07:55,940 Equal sign. 101 00:07:56,420 --> 00:07:59,240 And seven here. 102 00:08:00,020 --> 00:08:02,180 I will explain all of this code later. 103 00:08:04,560 --> 00:08:06,110 Seven equals equals. 104 00:08:06,120 --> 00:08:06,500 Oops. 105 00:08:06,510 --> 00:08:08,010 Not like that. 106 00:08:08,010 --> 00:08:11,760 Okay, Um, new line. 107 00:08:14,590 --> 00:08:16,660 Seven equals equals seven. 108 00:08:17,300 --> 00:08:17,690 Here. 109 00:08:18,920 --> 00:08:22,570 It will show us the numbers about that. 110 00:08:22,640 --> 00:08:34,190 This is a true or false, which I will explain later, as I always do when writing some codes. 111 00:08:34,610 --> 00:08:36,470 Inequality Sign. 112 00:08:39,290 --> 00:08:46,490 So I don't want to just drink my lectures time. 113 00:08:46,580 --> 00:08:50,260 So I will pause this lecture here. 114 00:08:50,270 --> 00:08:58,790 So after that, um, like I have to write like, uh, 5 or 6 lines of code or whatever. 115 00:08:58,820 --> 00:08:59,660 This is just. 116 00:08:59,780 --> 00:09:01,550 This will be quick enough. 117 00:09:02,290 --> 00:09:06,080 Um, so I promise this will look quick enough. 118 00:09:06,500 --> 00:09:09,050 So you watch here and learn. 119 00:09:09,320 --> 00:09:12,680 This is the unique inequality sign. 120 00:09:13,850 --> 00:09:16,250 Not equal to seven. 121 00:09:17,120 --> 00:09:18,440 Print f. 122 00:09:20,020 --> 00:09:22,360 Printf here. 123 00:09:23,050 --> 00:09:25,540 Ten greater than 12. 124 00:09:28,810 --> 00:09:31,120 What in 20 years. 125 00:09:31,120 --> 00:09:33,400 And this call. 126 00:09:34,900 --> 00:09:37,690 And greater than 20 127 00:09:40,030 --> 00:09:41,110 print f. 128 00:09:44,770 --> 00:09:49,060 Ten greater than or equal to 20. 129 00:09:51,240 --> 00:09:51,720 Here. 130 00:09:51,720 --> 00:09:56,370 New first format specifier for integer and boolean. 131 00:09:58,670 --> 00:10:00,410 In here and. 132 00:10:01,930 --> 00:10:02,650 Ten. 133 00:10:03,190 --> 00:10:05,590 Greater than or equal to 20. 134 00:10:07,290 --> 00:10:09,550 Here and print f. 135 00:10:11,410 --> 00:10:11,980 Ten. 136 00:10:11,980 --> 00:10:13,200 Less than 20. 137 00:10:15,420 --> 00:10:18,420 Format Specifiers always and new line. 138 00:10:19,630 --> 00:10:20,260 Ten. 139 00:10:20,470 --> 00:10:21,700 Less than 20. 140 00:10:25,220 --> 00:10:25,910 Okay. 141 00:10:25,910 --> 00:10:29,480 And last line print f. 142 00:10:33,240 --> 00:10:36,510 20 less than or equal to. 143 00:10:37,910 --> 00:10:38,540 20. 144 00:10:40,620 --> 00:10:41,730 Format specifier. 145 00:10:41,760 --> 00:10:42,810 New Line. 146 00:10:43,140 --> 00:10:44,790 And our compare. 147 00:10:44,850 --> 00:10:46,120 Our real comparison. 148 00:10:46,140 --> 00:10:48,120 So these are the just texts. 149 00:10:48,120 --> 00:10:49,710 So you can you can. 150 00:10:49,710 --> 00:10:50,970 Don't write. 151 00:10:51,300 --> 00:10:57,870 You can also don't write this text in this print function but wanted to write because of that. 152 00:10:57,870 --> 00:11:05,010 I want to show you how these comparison operators works with illustration here. 153 00:11:08,120 --> 00:11:10,850 20 less than or equal to 20. 154 00:11:13,000 --> 00:11:13,540 Here. 155 00:11:15,420 --> 00:11:18,300 So let's compile our code now. 156 00:11:18,960 --> 00:11:19,740 Clear. 157 00:11:22,120 --> 00:11:25,250 GCC main.cpp dot x. 158 00:11:26,170 --> 00:11:28,090 Here, as you can see here. 159 00:11:28,590 --> 00:11:29,370 So. 160 00:11:30,750 --> 00:11:38,850 Um, each comparison here, each comparison here produced a boolean result here. 161 00:11:40,890 --> 00:11:48,270 So and the print statement prints the boolean as integer 1 or 0. 162 00:11:49,160 --> 00:11:52,990 So let's look at this code and our output here. 163 00:11:53,000 --> 00:11:56,300 So seven is seven equals to seven. 164 00:11:56,510 --> 00:11:57,230 Yes. 165 00:11:57,230 --> 00:11:58,820 And this is the true. 166 00:11:58,820 --> 00:12:04,220 And the compiler gave us one is seven is not equal to seven. 167 00:12:04,830 --> 00:12:07,380 No, because seven is not. 168 00:12:07,530 --> 00:12:09,660 Seven is equal to seven. 169 00:12:09,660 --> 00:12:11,340 And this is false. 170 00:12:11,340 --> 00:12:14,490 So this gave us compiler gave us zero. 171 00:12:14,700 --> 00:12:16,440 Is ten greater than. 172 00:12:17,740 --> 00:12:18,430 20. 173 00:12:19,480 --> 00:12:24,280 No, because 20 is greater than ten and this gave us zero. 174 00:12:24,370 --> 00:12:28,030 Is ten greater than or equal to 20? 175 00:12:28,720 --> 00:12:30,220 Again, no. 176 00:12:30,520 --> 00:12:32,500 This gave us the zero. 177 00:12:32,500 --> 00:12:38,320 So false is ten less than 20. 178 00:12:40,160 --> 00:12:42,080 Yes, so true. 179 00:12:42,110 --> 00:12:45,170 This gave us the one here, as you can see here. 180 00:12:46,620 --> 00:12:54,030 So is 20 less than or equal to 20? 181 00:12:55,820 --> 00:12:58,340 So the answer is yes. 182 00:12:58,340 --> 00:13:02,630 So true because 20 is not less than. 183 00:13:02,630 --> 00:13:08,510 But here we have the second operator equality sign. 184 00:13:08,510 --> 00:13:11,360 So 20 is equal to 20. 185 00:13:16,880 --> 00:13:20,750 In next lecture, you will learn about the logical operators. 186 00:13:22,140 --> 00:13:24,360 So I'm waiting you in the next lecture.