title
CONDITIONS and BRANCHES in C++ (if statements)

description
Twitter ► https://twitter.com/thecherno Instagram ► https://instagram.com/thecherno Patreon ► https://patreon.com/thecherno Today we're going to be taking a look at conditions and branches in C++, which basically means if, else if, and else statements. This is an important part of logical programming where we decide to execute certain blocks of code depending on a certain condition. We go pretty in-depth in this video so make sure you watch until the end! Linked Videos: Debugging ► https://youtu.be/0ebzPwixrJA How the C++ Compiler Works ► https://youtu.be/3tIqpEmWMLI Variables in C++ ► https://youtu.be/zB9RI8_wExo Series Playlist ► https://www.youtube.com/playlist?list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb BEST laptop for programming! ► http://geni.us/pakTES My FAVOURITE keyboard for programming! ► http://geni.us/zNhB FAVOURITE monitors for programming! ► http://geni.us/Ig6KBq MAIN Camera ► http://geni.us/CYUQ MAIN Lens ► http://geni.us/ZM3CmG Microphone ► http://geni.us/wqO6g7K Slack ► https://slack.thecherno.com Stream ► http://www.twitch.tv/thecherno Website ► http://www.thecherno.com Facebook ► http://www.facebook.com/thecherno

detail
{'title': 'CONDITIONS and BRANCHES in C++ (if statements)', 'heatmap': [{'end': 488.641, 'start': 423.592, 'weight': 0.918}], 'summary': 'Delves into c++ conditionals, if statements, and assembly code execution, covering evaluation of conditions, branching, boolean variables, and usage of else and else if statements, providing comprehensive insights for both beginners and experienced programmers.', 'chapters': [{'end': 35.596, 'segs': [{'end': 49.525, 'src': 'embed', 'start': 20.905, 'weight': 0, 'content': [{'end': 24.068, 'text': 'but I do encourage you to still watch the video because you might learn something new.', 'start': 20.905, 'duration': 3.163}, {'end': 28.952, 'text': "I'm actually going to go a little bit deeper as to how it works in C++, so it's worth hanging around.", 'start': 24.208, 'duration': 4.744}, {'end': 31.834, 'text': 'Right. so what do I mean by conditions?', 'start': 29.312, 'duration': 2.522}, {'end': 34.035, 'text': 'or if statements or branching?', 'start': 31.834, 'duration': 2.201}, {'end': 35.596, 'text': 'What is all of this?', 'start': 34.575, 'duration': 1.021}, {'end': 45.702, 'text': 'Basically, there are certain times when we write our programs that we want to evaluate a certain condition and then decide what code we want to execute as a result of that evaluation.', 'start': 35.976, 'duration': 9.726}, {'end': 49.525, 'text': "So for example, let's say we have a variable called x and it's equal to five.", 'start': 46.003, 'duration': 3.522}], 'summary': 'The transcript discusses the concept of conditions and if statements in programming, specifically in the context of c++. it emphasizes the importance of evaluating conditions to decide which code to execute.', 'duration': 28.62, 'max_score': 20.905, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc20905.jpg'}], 'start': 0.149, 'title': 'C++ conditionals', 'summary': "Provides a comprehensive explanation of if statements and branching behavior in c++, aiming to deepen viewers' understanding and introduce new insights, even for those familiar with the concept.", 'chapters': [{'end': 35.596, 'start': 0.149, 'title': 'C++ conditionals explained', 'summary': 'Covers a comprehensive explanation of if statements and branching behavior in c++, encouraging viewers to understand the deeper workings and learn something new, despite already being familiar with the concept.', 'duration': 35.447, 'highlights': ['The chapter delves into a comprehensive explanation of if statements, else statements, and branching behavior in C++, with a focus on encouraging viewers to still watch the video despite their existing knowledge, as they might learn something new.', 'The instructor emphasizes the importance of understanding the deeper workings of if statements in C++ and encourages viewers to hang around to learn more.', 'The chapter addresses the misconception that viewers might already know everything about if statements and else statements in C++, and encourages them to still watch the video for potential new learnings.']}], 'duration': 35.447, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc149.jpg', 'highlights': ['The chapter delves into a comprehensive explanation of if statements, else statements, and branching behavior in C++, with a focus on encouraging viewers to still watch the video despite their existing knowledge, as they might learn something new.', 'The instructor emphasizes the importance of understanding the deeper workings of if statements in C++ and encourages viewers to hang around to learn more.', 'The chapter addresses the misconception that viewers might already know everything about if statements and else statements in C++, and encourages them to still watch the video for potential new learnings.']}, {'end': 518.792, 'segs': [{'end': 99.43, 'src': 'embed', 'start': 72.678, 'weight': 0, 'content': [{'end': 78.5, 'text': 'So, in other words, if our condition evaluates as true, we need to jump to a certain part of our source code.', 'start': 72.678, 'duration': 5.822}, {'end': 82.381, 'text': 'If the evaluation is false, we need to jump to another part of our source code.', 'start': 78.9, 'duration': 3.481}, {'end': 87.043, 'text': "And of course I'm saying source code, but in a running application, it really means machine instructions.", 'start': 82.661, 'duration': 4.382}, {'end': 94.285, 'text': 'So in other words, we branch to one section of our machine code, our CPU instructions, or we branch to another section of our CPU instructions.', 'start': 87.083, 'duration': 7.202}, {'end': 99.43, 'text': 'Now when we start an application, that entire application, along with all of its modules, gets loaded into memory.', 'start': 94.505, 'duration': 4.925}], 'summary': 'Conditional evaluation directs flow to different parts of source code or machine instructions; entire application is loaded into memory at start.', 'duration': 26.752, 'max_score': 72.678, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc72678.jpg'}, {'end': 156.593, 'src': 'embed', 'start': 122.532, 'weight': 1, 'content': [{'end': 135.642, 'text': 'the fact that we actually have to check a condition and then jump to a different portion of our memory and start executing instructions from there actually means that if statements and branches in general do carry a little bit of overhead.', 'start': 122.532, 'duration': 13.11}, {'end': 140.384, 'text': "And if you're trying to write very fast code, you might decide not to use if statements at all.", 'start': 135.962, 'duration': 4.422}, {'end': 147.848, 'text': "In fact, a lot of optimized code will specifically avoid branching, avoid if statements, because by doing so, it's gonna slow the program down.", 'start': 140.745, 'duration': 7.103}, {'end': 154.732, 'text': 'Eventually, in this series, we are going to be taking a look at some examples of optimization by doing things like removing branches,', 'start': 148.088, 'duration': 6.644}, {'end': 156.593, 'text': "but that's just way too early right now.", 'start': 154.732, 'duration': 1.861}], 'summary': 'Branches and if statements carry overhead, optimized code avoids them for faster execution.', 'duration': 34.061, 'max_score': 122.532, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc122532.jpg'}, {'end': 488.641, 'src': 'heatmap', 'start': 423.592, 'weight': 0.918, 'content': [{'end': 427.454, 'text': 'we could compile this to assembly and inspect the output assembly.', 'start': 423.592, 'duration': 3.862}, {'end': 433.096, 'text': "However, there's actually one more thing we could do as part of debugging, and that is view the disassembly of this current running code.", 'start': 427.494, 'duration': 5.602}, {'end': 437.937, 'text': 'So if we hit F5 to run our program with a breakpoint set, what I can do is right click here.', 'start': 433.256, 'duration': 4.681}, {'end': 442.979, 'text': 'This is once my application is paused, right? I can right click here and select go to disassembly.', 'start': 438.337, 'duration': 4.642}, {'end': 451.203, 'text': 'And then you can see I jump into this view where we have both our source code and then the associated assembly instruction that is that source code.', 'start': 443.439, 'duration': 7.764}, {'end': 459.427, 'text': 'So in other words, our compiler has compiled this source code into this line and this source code into all of these instructions.', 'start': 451.343, 'duration': 8.084}, {'end': 465.85, 'text': 'we can actually step through this assembly line by line and even take a look at what the registers in our cpu actually contain.', 'start': 459.847, 'duration': 6.003}, {'end': 466.531, 'text': "so it's pretty cool.", 'start': 465.85, 'duration': 0.681}, {'end': 472.654, 'text': "this disassembly view is actually amazingly useful when you're trying to debug either source code that you don't have access to, so in other words,", 'start': 466.531, 'duration': 6.123}, {'end': 475.055, 'text': 'you have to resort to actually debugging cpu instructions.', 'start': 472.654, 'duration': 2.401}, {'end': 478.817, 'text': "that's an absolute nightmare, by the way, trying to avoid that as much as you can.", 'start': 475.055, 'duration': 3.762}, {'end': 483.599, 'text': "but also it's really useful to quickly see what code the compiler has actually generated in,", 'start': 478.817, 'duration': 4.782}, {'end': 488.641, 'text': 'instead of setting up that whole outputting into a file stuff that I covered in my how the C++ compiler works.', 'start': 483.599, 'duration': 5.042}], 'summary': 'Debugging includes viewing disassembly, stepping through assembly, and inspecting cpu registers for efficient troubleshooting.', 'duration': 65.049, 'max_score': 423.592, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc423592.jpg'}, {'end': 494.823, 'src': 'embed', 'start': 466.531, 'weight': 4, 'content': [{'end': 472.654, 'text': "this disassembly view is actually amazingly useful when you're trying to debug either source code that you don't have access to, so in other words,", 'start': 466.531, 'duration': 6.123}, {'end': 475.055, 'text': 'you have to resort to actually debugging cpu instructions.', 'start': 472.654, 'duration': 2.401}, {'end': 478.817, 'text': "that's an absolute nightmare, by the way, trying to avoid that as much as you can.", 'start': 475.055, 'duration': 3.762}, {'end': 483.599, 'text': "but also it's really useful to quickly see what code the compiler has actually generated in,", 'start': 478.817, 'duration': 4.782}, {'end': 488.641, 'text': 'instead of setting up that whole outputting into a file stuff that I covered in my how the C++ compiler works.', 'start': 483.599, 'duration': 5.042}, {'end': 494.823, 'text': 'video. instead of setting all that up, we can just kind of look at it, look at the disassembly view and So back here.', 'start': 488.641, 'duration': 6.182}], 'summary': 'Disassembly view useful for debugging source code, avoids debugging cpu instructions, and quickly sees compiler-generated code.', 'duration': 28.292, 'max_score': 466.531, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc466531.jpg'}], 'start': 35.976, 'title': 'Conditional statements and c++ if statements', 'summary': 'Covers the concept of conditional statements, including evaluation of conditions, branching, and impact on performance, and explores the usage of if statements and comparison operators in c++, with practical examples and debugging techniques.', 'chapters': [{'end': 156.593, 'start': 35.976, 'title': 'Understanding conditional statements', 'summary': 'Discusses the concept of conditional statements, highlighting the evaluation of conditions, branching to appropriate code based on the evaluation, and the impact of branching on program performance.', 'duration': 120.617, 'highlights': ['The process of evaluating a condition and branching to the appropriate code based on the evaluation is crucial in programming.', 'Conditional statements, such as if statements, involve checking a condition and then jumping to a different portion of memory to execute instructions, which introduces some overhead.', 'Optimized code often avoids branching and if statements to improve program performance and avoid slowing down the program.']}, {'end': 518.792, 'start': 156.633, 'title': 'C++ if statement and boolean operators', 'summary': 'Discusses the usage of if statements and comparison operators in c++ to control the flow of the program, demonstrating the functionality with an example of a basic if statement, and exploring the debugging techniques including breakpoints and disassembly view.', 'duration': 362.159, 'highlights': ['The chapter discusses the usage of if statements and comparison operators in C++ to control the flow of the program Explains the concept of if statements and comparison operators as a way to control the flow of a C++ program.', 'demonstrating the functionality with an example of a basic if statement Provides an example of using a basic if statement to check a condition and execute a certain bunch of code based on the condition being true.', 'exploring the debugging techniques including breakpoints and disassembly view Explores the debugging techniques such as using breakpoints and disassembly view to understand the behind-the-scenes CPU instructions and inspect the output assembly of the program.']}], 'duration': 482.816, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc35976.jpg', 'highlights': ['The process of evaluating a condition and branching is crucial in programming.', 'Optimized code often avoids branching and if statements to improve program performance.', 'The chapter discusses the usage of if statements and comparison operators in C++ to control the flow of the program.', 'Explains the concept of if statements and comparison operators as a way to control the flow of a C++ program.', 'Exploring the debugging techniques including breakpoints and disassembly view.']}, {'end': 858.161, 'segs': [{'end': 581.866, 'src': 'embed', 'start': 557.191, 'weight': 1, 'content': [{'end': 564.495, 'text': "So in other words, if this comparison fails, Right now, this comparison, all it's really doing is comparing those two values, 5 and 6.", 'start': 557.191, 'duration': 7.304}, {'end': 568.277, 'text': "If they're not equal, we're going to be jumping to this memory address.", 'start': 564.495, 'duration': 3.782}, {'end': 574.141, 'text': 'Now, the memory address is actually this value here 01B59B7,, right?', 'start': 568.317, 'duration': 5.824}, {'end': 578.464, 'text': "So if we just look at the end of that, really 9B7, you can see that it's actually this line of code.", 'start': 574.501, 'duration': 3.963}, {'end': 581.866, 'text': "So if these are not equal, we're going to jump to this line of code.", 'start': 578.884, 'duration': 2.982}], 'summary': 'Comparison of values 5 and 6, if not equal, jumps to memory address 01b59b7.', 'duration': 24.675, 'max_score': 557.191, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc557191.jpg'}, {'end': 659.208, 'src': 'embed', 'start': 635.598, 'weight': 3, 'content': [{'end': 642.982, 'text': "But because we've got that huge one byte of addressable memory and if we create a boolean, it is actually going to occupy one byte of memory,", 'start': 635.598, 'duration': 7.384}, {'end': 647.164, 'text': "we don't necessarily have to make sure that that one bit is set to one.", 'start': 642.982, 'duration': 4.182}, {'end': 648.605, 'text': "so like it's really.", 'start': 647.164, 'duration': 1.441}, {'end': 653.046, 'text': "if anything there is not zero, then it's going to be true, right?", 'start': 648.605, 'duration': 4.441}, {'end': 659.208, 'text': "if we, if we were just dealing with one bit, of course, we'd only have two possible values zero and one and if it was zero, it would be false.", 'start': 653.046, 'duration': 6.162}], 'summary': 'One byte of addressable memory can store a boolean, with non-zero values being true.', 'duration': 23.61, 'max_score': 635.598, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc635598.jpg'}, {'end': 783.533, 'src': 'embed', 'start': 754.802, 'weight': 0, 'content': [{'end': 761.326, 'text': "so we only the fact that it says it's not a regular jump instruction, right, which is jmp, it's jump equal.", 'start': 754.802, 'duration': 6.524}, {'end': 763.448, 'text': "so it's only, it's a conditional jump statement.", 'start': 761.326, 'duration': 2.122}, {'end': 766.069, 'text': 'So in other words, if this fails,', 'start': 763.928, 'duration': 2.141}, {'end': 772.01, 'text': "then we're just going to advance to the next line of code which is here right? The next CPU instruction which is actually going to do all of this.", 'start': 766.069, 'duration': 5.941}, {'end': 776.651, 'text': 'However, we know that this test is going to succeed because comparison result is false.', 'start': 772.33, 'duration': 4.321}, {'end': 783.533, 'text': 'And so if we hit F10, you can see we actually do jump over here and we continue running our program kind of as normal.', 'start': 777.111, 'duration': 6.422}], 'summary': 'The instruction is a conditional jump, which successfully advances to the next line of code when the comparison result is false.', 'duration': 28.731, 'max_score': 754.802, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc754802.jpg'}, {'end': 841.435, 'src': 'embed', 'start': 807.151, 'weight': 4, 'content': [{'end': 809.052, 'text': "We don't have to do that comparison at runtime.", 'start': 807.151, 'duration': 1.901}, {'end': 811.555, 'text': 'We can actually see is six equal to five.', 'start': 809.373, 'duration': 2.182}, {'end': 812.956, 'text': 'We can do that at compile time.', 'start': 811.575, 'duration': 1.381}, {'end': 815.597, 'text': 'And so something called constant folding will happen.', 'start': 813.416, 'duration': 2.181}, {'end': 819.439, 'text': "So it'll turn this all into a constant variable because it is a constant variable.", 'start': 815.637, 'duration': 3.802}, {'end': 820.78, 'text': "All of it's known at compile time.", 'start': 819.499, 'duration': 1.281}, {'end': 828.705, 'text': "And then it's going to actually get rid of this if comparison result if statement altogether and leave us with just stdcn.get.", 'start': 821.461, 'duration': 7.244}, {'end': 834.449, 'text': "it'll just remove basically lines six through 11 because they're never going to run.", 'start': 829.585, 'duration': 4.864}, {'end': 841.435, 'text': "So why compile them? Why do that? Why do that conditional check at runtime? That's just going to take extra time and we clearly don't need it.", 'start': 834.509, 'duration': 6.926}], 'summary': 'Constant folding at compile time removes unnecessary conditional check, improving efficiency.', 'duration': 34.284, 'max_score': 807.151, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc807151.jpg'}], 'start': 518.792, 'title': 'Assembly code execution and boolean variables', 'summary': 'Explores the execution flow of assembly code, detailing loading values into registers, comparison statements, and conditional jumps. it also delves into the concept of boolean variables in assembly, discussing the interpretation of zeros and non-zero values as false and true, along with insights into conditional statements and compiler optimizations.', 'chapters': [{'end': 598.615, 'start': 518.792, 'title': 'Understanding assembly code execution', 'summary': 'Explains the execution flow of assembly code, including loading values into registers, comparison statements, and conditional jumps, with an example of comparing 5 and 6 and jumping to a specific memory address if they are not equal.', 'duration': 79.823, 'highlights': ['The comparison between 5 and 6 in the assembly code triggers a jump to a specific memory address if the values are not equal, demonstrating the execution flow of the code.', 'The process involves loading a register with a value, specifically moving the value 6 into a register, followed by loading 5 into the same register before the comparison.', 'The JNE (jump not equals) instruction is utilized to handle the conditional jump based on the result of the comparison between the loaded values, showcasing the decision-making process within the code execution.', 'The specific memory address 01B59B7 is targeted for the potential jump when the comparison fails, providing insight into the memory management and control flow of the assembly code.']}, {'end': 858.161, 'start': 598.615, 'title': 'Understanding boolean variables in assembly', 'summary': 'Explains the concept of boolean variables in assembly, detailing how zeros and non-zero values are interpreted as false and true respectively, along with insights into conditional statements and compiler optimizations.', 'duration': 259.546, 'highlights': ['Boolean variables in assembly are represented by one byte of memory, where zero is interpreted as false and any non-zero value is considered true. Boolean variables are stored as one byte of memory, with zero representing false and any non-zero value representing true.', 'The chapter provides insights into conditional statements in assembly by explaining the test instruction and conditional jump operations based on comparison results. The chapter delves into conditional statements, explaining the test instruction and conditional jump operations based on comparison results.', 'Compiler optimizations such as constant folding are highlighted, indicating the elimination of unnecessary conditional checks at runtime through compile-time analysis. The chapter discusses compiler optimizations, specifically constant folding, which eliminates unnecessary conditional checks at runtime through compile-time analysis.']}], 'duration': 339.369, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc518792.jpg', 'highlights': ['The JNE (jump not equals) instruction is utilized to handle the conditional jump based on the result of the comparison between the loaded values, showcasing the decision-making process within the code execution.', 'The comparison between 5 and 6 in the assembly code triggers a jump to a specific memory address if the values are not equal, demonstrating the execution flow of the code.', 'The specific memory address 01B59B7 is targeted for the potential jump when the comparison fails, providing insight into the memory management and control flow of the assembly code.', 'Boolean variables in assembly are represented by one byte of memory, where zero is interpreted as false and any non-zero value is considered true. Boolean variables are stored as one byte of memory, with zero representing false and any non-zero value representing true.', 'Compiler optimizations such as constant folding are highlighted, indicating the elimination of unnecessary conditional checks at runtime through compile-time analysis. The chapter discusses compiler optimizations, specifically constant folding, which eliminates unnecessary conditional checks at runtime through compile-time analysis.']}, {'end': 1082.132, 'segs': [{'end': 906.063, 'src': 'embed', 'start': 878.543, 'weight': 2, 'content': [{'end': 883.606, 'text': 'However, if it is anything other than zero, such as one, it is going to jump into that if statement.', 'start': 878.543, 'duration': 5.063}, {'end': 890.051, 'text': "That's kind of why this whole thing works, and we don't have to do something like equals equals true, because we don't need to be checking hey,", 'start': 883.766, 'duration': 6.285}, {'end': 892.633, 'text': 'is it equal to one, or is it equal to true or anything like that?', 'start': 890.051, 'duration': 2.582}, {'end': 896.035, 'text': 'we can just kind of say hey, is this value not zero?', 'start': 893.033, 'duration': 3.002}, {'end': 897.316, 'text': "That's really what this is doing.", 'start': 896.075, 'duration': 1.241}, {'end': 900.839, 'text': "It's saying take a look at the memory behind comparison result.", 'start': 897.356, 'duration': 3.483}, {'end': 902.44, 'text': 'right?. What is comparison result?', 'start': 900.839, 'duration': 1.601}, {'end': 903.321, 'text': 'Is it zero??', 'start': 902.62, 'duration': 0.701}, {'end': 906.063, 'text': "If it's not zero, then execute this code.", 'start': 903.801, 'duration': 2.262}], 'summary': 'The code checks if the comparison result is not zero and executes the code accordingly.', 'duration': 27.52, 'max_score': 878.543, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc878543.jpg'}, {'end': 957.791, 'src': 'embed', 'start': 933.411, 'weight': 1, 'content': [{'end': 939.636, 'text': 'you can just write if x equals, equals five over here, and that will simplify your code quite a bit.', 'start': 933.411, 'duration': 6.225}, {'end': 944.38, 'text': "if our if statement is just one line of code as well, we don't need to provide curly brackets for a body.", 'start': 939.636, 'duration': 4.744}, {'end': 947.163, 'text': 'we can just write something like this and it will be fine.', 'start': 944.38, 'duration': 2.783}, {'end': 948.724, 'text': 'You can even format this.', 'start': 947.583, 'duration': 1.141}, {'end': 950.405, 'text': 'Some people format this to be on one line.', 'start': 948.764, 'duration': 1.641}, {'end': 951.586, 'text': 'I personally do not do that.', 'start': 950.565, 'duration': 1.021}, {'end': 957.791, 'text': "It's a little bit annoying when it's on one line, because if you're trying to debug, so, for example, if I put a breakpoint here,", 'start': 952.006, 'duration': 5.785}], 'summary': "Using 'x == 5' simplifies code; one-line if statements don't need curly brackets.", 'duration': 24.38, 'max_score': 933.411, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc933411.jpg'}, {'end': 998.057, 'src': 'embed', 'start': 968.22, 'weight': 0, 'content': [{'end': 972.528, 'text': 'Whereas if I do separate it out into two lines like this, I can actually check.', 'start': 968.22, 'duration': 4.308}, {'end': 975.814, 'text': "You can see that if I hit F10, look, it's not going to that line.", 'start': 972.608, 'duration': 3.206}, {'end': 977.758, 'text': 'So clearly that line has not been executed.', 'start': 975.854, 'duration': 1.904}, {'end': 979.157, 'text': 'Nice and simple.', 'start': 978.536, 'duration': 0.621}, {'end': 985.464, 'text': 'Because booleans are just numeric values and because this if statement is basically just checking something numerically.', 'start': 979.457, 'duration': 6.007}, {'end': 987.566, 'text': 'you can do some pretty interesting things with if statements.', 'start': 985.464, 'duration': 2.102}, {'end': 990.329, 'text': 'For example, I can just write if x right?', 'start': 987.606, 'duration': 2.723}, {'end': 998.057, 'text': "And then if I run that code, it's going to basically be again evaluating hey, is x zero or is it not?", 'start': 990.91, 'duration': 7.147}], 'summary': 'Demonstration of using if statements to evaluate numeric values in code.', 'duration': 29.837, 'max_score': 968.22, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc968220.jpg'}, {'end': 1062.096, 'src': 'embed', 'start': 1035.147, 'weight': 4, 'content': [{'end': 1039.433, 'text': "And because of that we're going to be able to print that to the console over here, okay?", 'start': 1035.147, 'duration': 4.286}, {'end': 1047.583, 'text': 'And if pointer was equal to null, so it could be zero or null pointer, or whatever you want to type, you can see that this code will not run, okay?', 'start': 1039.733, 'duration': 7.85}, {'end': 1054.769, 'text': 'So basically, instead of writing if pointer does not equal null pointer, we can be a little bit more concise and just write if pointer.', 'start': 1047.803, 'duration': 6.966}, {'end': 1056.591, 'text': 'Now this is more of a matter of style as well.', 'start': 1055.03, 'duration': 1.561}, {'end': 1060.795, 'text': 'Some people do like to be explicit because they claim that it makes the code a little bit more readable.', 'start': 1056.631, 'duration': 4.164}, {'end': 1062.096, 'text': "I personally don't mind.", 'start': 1061.175, 'duration': 0.921}], 'summary': "Code optimization by using 'if pointer' instead of 'if pointer does not equal null pointer' for improved readability.", 'duration': 26.949, 'max_score': 1035.147, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc1035146.jpg'}], 'start': 858.161, 'title': 'If statements in programming', 'summary': 'Explores the functionality and usage of if statements in programming, covering boolean comparison, handling non-zero and zero values, and discussing their usage in c++ for evaluating conditions, including booleans, numeric values, and pointers, and demonstrating concise and explicit styles of writing if statements.', 'chapters': [{'end': 951.586, 'start': 858.161, 'title': 'Understanding if statements in programming', 'summary': 'Explains how if statements in programming work with boolean comparison results, showing that non-zero values execute the if statement, while zero values do not. it also highlights the simplicity of if statements and their formatting.', 'duration': 93.425, 'highlights': ['if statement checks if a number is zero or not, executing code based on the result. The if statement checks if a number is zero, and if it is not zero, it executes the associated code. This simplifies the process as it eliminates the need to check for equality to true, and just focuses on the non-zero condition.', 'Non-zero values, such as 1, will execute the if statement, while zero values will not. Non-zero values, such as 1, trigger the execution of the if statement, while zero values do not. This provides a clear understanding of how if statements work based on Boolean comparison results.', 'Simplicity and formatting of if statements in programming. If statements can be simplified by not requiring curly brackets for a single line of code and can be formatted according to personal preference, offering flexibility in code organization.']}, {'end': 1082.132, 'start': 952.006, 'title': 'Use of if statements in c++', 'summary': 'Discusses the usage of if statements in c++ to evaluate conditions, including the use of booleans, numeric values, and pointers, illustrating how to check for null pointers and demonstrating the concise and explicit styles of writing if statements.', 'duration': 130.126, 'highlights': ['The chapter discusses the usage of if statements in C++ to evaluate conditions The discussion revolves around how if statements are used to evaluate conditions in C++', 'Illustrating how to check for null pointers The transcript demonstrates how to use if statements to check whether a pointer is null or not', 'Including the use of booleans, numeric values, and pointers The usage of booleans, numeric values, and pointers in if statements is explained', 'Demonstrating the concise and explicit styles of writing if statements The transcript showcases both concise and explicit styles of writing if statements in C++']}], 'duration': 223.971, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc858161.jpg', 'highlights': ['The chapter discusses the usage of if statements in C++ to evaluate conditions', 'Demonstrating the concise and explicit styles of writing if statements', 'Non-zero values, such as 1, will execute the if statement, while zero values will not', 'The if statement checks if a number is zero or not, executing code based on the result', 'Illustrating how to check for null pointers']}, {'end': 1405.283, 'segs': [{'end': 1105.527, 'src': 'embed', 'start': 1082.572, 'weight': 4, 'content': [{'end': 1091.443, 'text': "Now, if we want to do something else, right? So basically I'm saying here, if pointer is a valid value, right? If it's not null, then log.", 'start': 1082.572, 'duration': 8.871}, {'end': 1096.769, 'text': "But what if I want to run some code that only happens if this is not the case, right? That's where an else statement comes in.", 'start': 1091.503, 'duration': 5.266}, {'end': 1100.334, 'text': 'So I can write else log pointer is null.', 'start': 1096.849, 'duration': 3.485}, {'end': 1105.527, 'text': "And then if I run my program right now, you can see what's going to happen.", 'start': 1102.263, 'duration': 3.264}], 'summary': 'Explaining the use of if-else statements in programming for handling null values.', 'duration': 22.955, 'max_score': 1082.572, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc1082572.jpg'}, {'end': 1210.735, 'src': 'embed', 'start': 1181.515, 'weight': 0, 'content': [{'end': 1184.017, 'text': 'And we actually end up printing two things to the console.', 'start': 1181.515, 'duration': 2.502}, {'end': 1185.338, 'text': 'So just something to keep in mind.', 'start': 1184.297, 'duration': 1.041}, {'end': 1191.663, 'text': 'Now, an else if statement is actually a little bit of a trick that you might not realize is actually happening to you.', 'start': 1185.598, 'duration': 6.065}, {'end': 1194.605, 'text': "It's really just kind of cleverly hidden syntax in a way.", 'start': 1191.783, 'duration': 2.822}, {'end': 1201.771, 'text': "So if we jump back to our code, what we'll see if I try and write this else if statement is it is actually two separate statements.", 'start': 1194.645, 'duration': 7.126}, {'end': 1205.314, 'text': "It's an else and it's an if, completely separate, because check this out.", 'start': 1202.131, 'duration': 3.183}, {'end': 1210.735, 'text': 'that is exactly what happens, right?', 'start': 1208.652, 'duration': 2.083}], 'summary': 'The discussion covers printing two things to the console and the nature of else if statements.', 'duration': 29.22, 'max_score': 1181.515, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc1181515.jpg'}, {'end': 1290.758, 'src': 'embed', 'start': 1252.563, 'weight': 3, 'content': [{'end': 1255.547, 'text': 'Else if is literally just, there is no else if keyword in C++.', 'start': 1252.563, 'duration': 2.984}, {'end': 1262.888, 'text': "There's just, there's else and there's if, right? And all we're doing here is we're saying else, if, right? Pretty cool.", 'start': 1255.567, 'duration': 7.321}, {'end': 1269.85, 'text': "All right, so anyway, I've said pretty much all I can about the basics of if statements and conditionals and branches and jumps and all of that stuff.", 'start': 1263.128, 'duration': 6.722}, {'end': 1272.131, 'text': 'Hope you guys understand how this all works.', 'start': 1270.191, 'duration': 1.94}, {'end': 1274.212, 'text': "So I'm pretty sure I covered like everything.", 'start': 1272.411, 'duration': 1.801}, {'end': 1277.313, 'text': "If you didn't get much, don't worry, I've made this very complicated.", 'start': 1274.232, 'duration': 3.081}, {'end': 1284.296, 'text': 'But on the other hand, I have shown you a little bit extra than I think most tutorials on if statements probably would have.', 'start': 1277.413, 'duration': 6.883}, {'end': 1287.557, 'text': "We'll be using if statements everywhere in our code.", 'start': 1284.676, 'duration': 2.881}, {'end': 1290.758, 'text': "There's two real, There's two real parts to programming.", 'start': 1287.617, 'duration': 3.141}], 'summary': "C++ doesn't have else if keyword. if statements are extensively covered, offering more than most tutorials.", 'duration': 38.195, 'max_score': 1252.563, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc1252563.jpg'}, {'end': 1334.697, 'src': 'embed', 'start': 1310.303, 'weight': 1, 'content': [{'end': 1316.685, 'text': 'Instead of the second part of programming or the second kind of section of programming that I call logical programming, Which is all about logic,', 'start': 1310.303, 'duration': 6.382}, {'end': 1319.686, 'text': 'right?. So hey, if this is this, then do that right.', 'start': 1316.685, 'duration': 3.001}, {'end': 1323.767, 'text': "if this, then that that's kind of a little bit more boring.", 'start': 1319.686, 'duration': 4.081}, {'end': 1324.928, 'text': "I'm not saying that.", 'start': 1323.767, 'duration': 1.161}, {'end': 1326.208, 'text': "I'm not saying that it doesn't have a place.", 'start': 1324.928, 'duration': 1.28}, {'end': 1327.008, 'text': 'Of course it does.', 'start': 1326.248, 'duration': 0.76}, {'end': 1334.697, 'text': "It's you can't write a There is no game written, there is no real application or game written without using if statements or anything like that.", 'start': 1327.189, 'duration': 7.508}], 'summary': 'Logical programming is essential for writing games and applications.', 'duration': 24.394, 'max_score': 1310.303, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc1310303.jpg'}], 'start': 1082.572, 'title': 'Using else and else if statements in programming', 'summary': 'Covers the usage of else and else if statements in programming to handle different conditions, emphasizing their implementation and importance in logical programming. it also explains the concept of else if statements in c++, highlighting their combination of else and if statements and their significance in handling multiple conditions.', 'chapters': [{'end': 1162.261, 'start': 1082.572, 'title': 'Introduction to else statements in programming', 'summary': 'Explains the usage of else statements in programming, demonstrating their implementation to handle different conditions and execute code based on the specified conditions, emphasizing the usage of else if to check for multiple conditions.', 'duration': 79.689, 'highlights': ['The chapter explains the usage of else statements in programming. It introduces the concept of using else statements to execute code based on a condition being false.', 'Demonstrating the implementation to handle different conditions. It provides an example of using else to execute code if a condition is false, showcasing the handling of null pointer and the corresponding code execution.', 'Emphasizing the usage of else if to check for multiple conditions. It highlights the usage of else if to check for additional conditions, demonstrating its role in handling specific scenarios based on the failure of prior conditions.']}, {'end': 1405.283, 'start': 1163.16, 'title': 'Understanding else if statements', 'summary': 'Discusses the concept of else if statements in c++, explaining how they are essentially a combination of else and if statements and how they are used in logical programming. it also highlights the importance of understanding the basics of if statements and conditionals in programming.', 'duration': 242.123, 'highlights': ['The chapter explains that else if statements in C++ are essentially a combination of else and if statements, rather than a distinct keyword, providing a new perspective on their usage in programming. The chapter reveals that else if statements in C++ are essentially a combination of else and if statements, providing a new understanding of their usage in programming.', 'The importance of understanding the basics of if statements and conditionals in programming is emphasized, as they form the foundation of logical programming, shedding light on their significance in software development. The chapter emphasizes the significance of understanding the basics of if statements and conditionals in programming, particularly in the context of logical programming.', 'The chapter discusses the division of programming into mathematical and logical programming, highlighting the prevalence and importance of if statements in logical programming, providing insights into the different aspects of programming. The chapter delves into the division of programming into mathematical and logical programming, emphasizing the importance of if statements in the logical programming aspect of software development.']}], 'duration': 322.711, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qEgCT87KOfc/pics/qEgCT87KOfc1082572.jpg', 'highlights': ['The chapter emphasizes the usage of else if to check for multiple conditions.', 'The chapter discusses the division of programming into mathematical and logical programming, highlighting the prevalence and importance of if statements in logical programming.', 'The chapter explains the usage of else statements in programming, introducing the concept of using else statements to execute code based on a condition being false.', 'The chapter reveals that else if statements in C++ are essentially a combination of else and if statements, providing a new understanding of their usage in programming.', 'The chapter provides an example of using else to execute code if a condition is false, showcasing the handling of null pointer and the corresponding code execution.', 'The chapter emphasizes the significance of understanding the basics of if statements and conditionals in programming, particularly in the context of logical programming.']}], 'highlights': ['The JNE (jump not equals) instruction is utilized to handle the conditional jump based on the result of the comparison between the loaded values, showcasing the decision-making process within the code execution.', 'Compiler optimizations such as constant folding are highlighted, indicating the elimination of unnecessary conditional checks at runtime through compile-time analysis. The chapter discusses compiler optimizations, specifically constant folding, which eliminates unnecessary conditional checks at runtime through compile-time analysis.', 'The process of evaluating a condition and branching is crucial in programming.', 'The chapter discusses the usage of if statements and comparison operators in C++ to control the flow of the program.', 'Explains the concept of if statements and comparison operators as a way to control the flow of a C++ program.', 'The chapter delves into a comprehensive explanation of if statements, else statements, and branching behavior in C++, with a focus on encouraging viewers to still watch the video despite their existing knowledge, as they might learn something new.', 'The instructor emphasizes the importance of understanding the deeper workings of if statements in C++ and encourages viewers to hang around to learn more.', 'The chapter addresses the misconception that viewers might already know everything about if statements and else statements in C++, and encourages them to still watch the video for potential new learnings.', 'The chapter emphasizes the usage of else if to check for multiple conditions.', 'The chapter discusses the division of programming into mathematical and logical programming, highlighting the prevalence and importance of if statements in logical programming.', 'The chapter explains the usage of else statements in programming, introducing the concept of using else statements to execute code based on a condition being false.', 'The chapter reveals that else if statements in C++ are essentially a combination of else and if statements, providing a new understanding of their usage in programming.', 'The chapter provides an example of using else to execute code if a condition is false, showcasing the handling of null pointer and the corresponding code execution.', 'The chapter emphasizes the significance of understanding the basics of if statements and conditionals in programming, particularly in the context of logical programming.', 'Optimized code often avoids branching and if statements to improve program performance.', 'The specific memory address 01B59B7 is targeted for the potential jump when the comparison fails, providing insight into the memory management and control flow of the assembly code.', 'Boolean variables in assembly are represented by one byte of memory, where zero is interpreted as false and any non-zero value is considered true. Boolean variables are stored as one byte of memory, with zero representing false and any non-zero value representing true.', 'Non-zero values, such as 1, will execute the if statement, while zero values will not', 'The if statement checks if a number is zero or not, executing code based on the result', 'Illustrating how to check for null pointers', 'Demonstrating the concise and explicit styles of writing if statements', 'The chapter discusses the usage of if statements in C++ to evaluate conditions']}