 All right, welcome back to 105. So thank you for joining me today this evening. Today we get to talk about if statements or, in other words, essentially the only reason why your computer looks like it is smart, even a little bit. So up till now, if we've been following the course right now, our programs, they always do the same thing. When you run main, it just runs line by line. It just stupidly goes from the next line to the next line to the next line until eventually it does a return and then it's done. The input may be different. So like if we take an integer, maybe we can type in a different integer. But that's about it. It's not really anywhere close to a real program that will do anything slightly complicated. But after today with if statements, that will form the foundation of being able to do different things. So there is a way to conditionally run code. So we only run code sometimes instead of all the time. And it is called an if statement. And it basically uses a Boolean to decide whether or not to execute some code. So the syntax, which again is just the rules of the C language. So how I have to write it in using my keyboard, I guess it's not kind of English. So what I have to do for an if statement is I write if. So that is a reserved keyword. So I'm not allowed to name a variable if or anything like that. Then bracket, then an expression. So something that actually results in a value. In this case, that expression should be a result in a Boolean. And then a statement that will run if it is true and if it is false, it will just skip that statement. So writing it like this, you can write an if statement like that. But generally, it's a bad idea. It's been a source of some very, very hard to debug issues that have come up. In fact, using this type of if statement actually resulted in one of the largest security breaches there's been in quite a long time. So don't write it like that for this course. Always write it like this. So you're sure what runs when that statement is true. So write if expression and then do the curly bracket. And then you can write a whole bunch of statements between the curly brackets. And they will run only if that expression is true. And again, expression, just a combination of operands and operators. So far, we've seen addition, subtraction, multiplication, that fun mod 1, division. And they've all resulted in another number, be it a double or an int. We don't really have anything that results in a boolean. So that's what we get to learn today. Oh, and yeah, before that, so just again to say that statements only run if that expression is true. So C will compute the results of that expression, convert it to a boolean if it's not already and a boolean is either zero false or one true. So if that expression is true or it's a one, it will run the statements between the curly brackets. And after it's done, it will run the next statement after the curly bracket. If the expression is false, it just immediately skips right here to the very end. So it will not run that code. So the expression in an if statement, it will convert to a boolean. We probably need to know some operators that actually result in a boolean instead of a number. So they are relational operators and they work with number arguments and then result in a boolean value. So these are all of them that you will use. So there is equal equals in math. That just means a single equal sign. So that's comparing if two numbers are the same as one another. So in C, it is equals equals, not equals because remember just a single equal sign, that means assignment. That means I'm updating a variable. So that may be the source of some issues you have. So whenever you want to compare two values, remember to always use equal equals. And that just means a single equal sign in math. You will have problems if you just use a single equal sign and you do assignment. So a exclamation mark equals, that's the same as saying not equals. In computing, we generally just say this exclamation mark is short for not. So this just kind of translates directly to not equals. So in math, you know, that's a sign equal sign with a slash through it. Can't write that just using a keyboard. So we have to use not equals. Then there's less than, so means less than, hopefully that one's self-evident. And then it's less than or equal to. So it's just the less than and then an equal sign. So that's the same as less than or equal to in math. And again, there's greater than which is greater than and then greater than or equal to, or at least how I remember the greater than or equal to. Did you learn like the crocodile goes and eats the thing at the bigger side? No? Okay, some of us might have, like even if you've done your PhD and stuff you still remember it like that. So I still remember the little alligator eating stuff to figure out which side is which. So don't worry about. All right. So some examples is I can see if two numbers are equal to each other. Remember, these could be variables as well. It's generally why I do it. Just writing is two equal to probably isn't the smartest thing. But serves as an example. So I could write two equal equal to and then the result of that is true. So two does equal to at least in this universe. I could also ask, hey, is three less than two? In this case, you know, the alligator is not eating the bigger number. So it is false. So we would result in zero. And then I might ask, hey, is three greater or equal to three? In which case that would be true. So I would get a one. So any questions about those operators? So those will take numbers and then we will be able to get a Boolean out of them. So those relational operators, they follow similar type rules to mixing ints and doubles. So if both operands are an int, then it does the operator just using integers. If at least one of the operands is a double, the other gets implicitly converted to a double if it's not on already. And then that operator just uses the real numbers or the doubles. So that's just done for the comparison. Sometimes comparing doubles gets really weird. So in general, if you have to compare doubles, we never use equal equals for reasons we will not get into. But it doesn't really matter. The result in either case is going to be a Boolean at the end of it. So is this true or is this false? So some other examples. In this case, if I write two equals equals two. So in this case, two is an int and 2.0 is a double. Well, what will happen is this two gets converted to a double. So it'll get converted to 2.0 and then 2.0 is the same as 2.0. So the final result would just be a one. So any questions about those operators right now? So just using those fairly straightforward operators, we can actually create programs that actually do something more complicated. Other operators we might use are some operators that only work with Booleans. So these operators are called logical operators. So they let us kind of connect Booleans together in order to come up with a more complicated condition. So all the operands are Booleans in this case and then the result is a Boolean. And thankfully, there's much fewer of these. So there is these two lines. So the two lines, that just means a logical, oh crap, I screwed them up. So these two lines, sorry, these two lines are mixed up. I'll fix that in the slides later. So these two lines are a logical or. So that means this or this is true. So in that case, if one of them is true, then the whole statement is true. And the only way that this statement is false is if both of them are false. So that's like, I don't know, I'm going to get up in the morning if it's sunny and warm out. And then, well, if it's neither of those, then you're not gonna get up. But if one is true, then you get up. So these two and operators, they mean logical and. So the result is only true if both sides are true. So if I say, you know, I'm going to get up again, if it's sunny and it's warm, then I will only get up out of bed if both of those are true. So as long as one of those is false, I'm staying in bed in the morning. And then there's also this unary operator that's just called not. And all it does is it flips the value. So if you say not true, the result is false. If you say not false, the result is true. So sometimes it's easier to say that like, hey, I'll wake up if it's not snowing or something like that. So any questions on those operators other than I screwed up the lines here? Yep. Yeah, so this operator here is logical or. And then this is logical and, and I will fix the slide after, but it makes sense because the operand, or the ampersand is an and, so that means logical and. And there is an operator that's just one of these in C, so one line and one ampersand. We will not cover what those do in this course. They do something else. So you will probably have some weird results if you actually type in just a single ampersand instead of two. So some examples here is if I have, if I do one and and one, well then both sides are true. So the final result here is going to be true. If I do zero and one, well that final result is false because they both need to be true in order for that entire expression to be true. If I do one or zero, well that is true because one of them is true. So the entire thing is true. And then if I do zero or zero, well that's just zero because they're both false. So the whole thing is false. And again, not one is equal to zero and then not zero is equal to one. So any questions about these? So they make a bit more sense when we actually have a program and tie them together, which we'll get into shortly. So some other rules because C allows you to write a bunch of silly things. So C does have rules for converting numbers to booleans if it's not already a boolean. Generally you should use one of the relational arguments all the time because if you don't, these rules are kind of weird because if C wants a boolean, so if it's an if statement, it will convert or cast that value to a boolean. And as a general rule, it gets a bit weird. So if the number represents zero, it gets converted to zero. Otherwise it gets converted to a one, which sometimes will be really weird for doubles. So for instance, if you say if 0.4, which is a double, then C is going to say, hey, that's not zero. So that's true, which gets really weird. So try and always use the relational operators here. So where we're at in precedence, a lot of rules so we'll get into some examples later is the higher precedence. So to connect them to things we already know, these are multiply, divide, mod, and then we have addition of subtraction. So all of the relational operators are lower precedence. So I would do all the math operations first or all the arithmetic first, and then I would do the relational operators. So here's the less sense, and then here's if one value is equal to another or not equal, and then our logical operators. So our ands and our oars that are a lower precedence. So it will always favor doing the ands before the oars. So just rules. Generally you should just probably get used to writing brackets around stuff instead of just remembering these precedence rules. So what can I do? Oh, yep. So how hard is this going to be tested on? We're not going to, we're going to ask you to write programs and they should work. So we're not going to say, hey, what's the precedence of this? But while you're doing that, if you can't remember, just put brackets around what you mean. So even like more brackets doesn't really hurt anything. So when in doubt, just use brackets to get what you mean. Because honestly, I forget some of them. So let us write our first program that does something using an if statement after all that blabbering. So we can now write a program where we can input an integer and it will do something, well, more than nothing, we can write an if statement. So we can do a scan F, get that number into that int called num, and then afterwards we can do an if statement. So we can say if num mod two is equal to zero. So that's saying if I divide two by one, my remainder is zero, which is another way of saying the number is even. So if the number is even, I will print off, it is even. So if I go ahead and run that, then someone showed a number to write. Anyone? Nine, all right. So nine, nothing happens for a nine because it is not an even number. If I want to see the if statement actually run this print F, well, I have to give it an even number, in which case I can say eight, and then it will print off, this is even. So now it is only doing this print line only if this condition is true. So only in this case, if we divide the number by two and the remainder is zero, we'll print off that the number is even. So any questions about that? Kind of cool, we're leveling up our skills. So this is a program that does something more exciting than just doing some calculation. And printing out the value. So now we're optionally just printing a line only if a certain condition is true, which is one of our first steps to writing real programs. So programs in the slides, so don't worry about it. And just in case any was confused about what statements run. So the same thing is true. It will start executing at main and then follow statement by statement. So it would run printf, input an integer, then int num equals zero, and then that scanf. And then the way you can think of the if statement is, what it will do is compute the value of this expression. So previously in the expression, I had num mod two equal equal to zero. So what it's going to do is compute the result of this. So in this case, if I enter, I don't know, eight, then eight mod two is zero, and then zero equal equal zero. So the result of that is true. So what we say is we go down, we call these branches. So we say we go down the true branch in that case, because well, we had an even number. So in that case, it would run printf, the number is even. And then after printing that, it would just go to return exit success. If in fact, like what I had before when I inputted a nine, well, this expression would be false, and then I would skip directly to return true, and I wouldn't see that print statement. And yeah, question and discord, do they give part marks on the midterms if our program isn't perfect? And the answer to that is yes, a human gets to grade it. So it's mostly in this course, at least on exams, thinking about your logic and making sure that what you're actually writing makes sense. Yep, yeah, so the exams, they're closed book exams just on paper, and the programming stuff is just through the labs. Yep, all right, any other questions about the structure here of this if statement? Yep, yeah, so if it becomes false, we follow this line here. So this is the line we follow here if it's false, and it goes immediately right to that return. So it skips over the print, right? Yeah, all right, any other questions what we have here? Yep, yeah, so the question is, essentially if I go back, is it bad practice if I just do like get rid of the curly brackets like this, and just write it all in one line? So yeah, that would probably be considered bad practice because it's really easy to like just write a line here and assume it runs if it's true, and it won't, in this case, it'll only run that single printed line, and usually it makes it harder to read. So for this course, like people that have been programming for 30 years have tried to like save the curly brackets and it cost, I don't know what the total amount was, like several billion dollars, so just always use the curly brackets, it makes it easier to read. All right, any other questions with what's going on here? All right, so, oh, and then there's a question, can we use exit success instead of return zero in the lab? And for that, sure, you can use that in the lab if you want. Generally, good practice not to have magic numbers. If you wanna remember the magic number zero, go for it. You might find that exit success is easier, and you always have to do all your include statements or something bad will happen, or it just won't be able to find the values. So if I want to use this exit success, I need this include here for standard lib because that's where that value actually lives, that's where it's defined. Alrighty, so let us level up our skills a bit more. So we might ask ourselves, oh, okay, well, we can optionally run some code if a condition is true. What about to just run some different code if that is false? Because right now, if it's false, we just skip over whatever the statements were and just go right to the end. So another valid syntax of an if statement is if expression, then a statement, and then else a statement. But again, we should always write the curly brackets just so the structure of the code is very, very clear. So we should write if expression statements, and then else statements. And what this will do is it will only run these statements if the expression is true, and then otherwise it will only run these statements if that expression is false. So each time through, I will either execute one or the other, but never both. So if it's true, I will run this. If it's false, I will run this. And then no matter what, the code will resume running at the end of this. So questions about that. Probably easier just to see it. So again, just so it's on the slides, only the statements between the curly brackets will run after the else. And these statements here between the else only run if that condition is false. So we can actually change our code a bit more and do something like this. So now we can use that else statement. So now instead of printing nothing if the number is even, well, I could have the same program, but I will write an else here. So if the number is not even, this will run and I will just print off the number is odd. So now if I run this program odd or even, then if I input eight, it should do what it did originally. So if it is eight, that means this expression is true. So it will run this print F and then it is done writing or running all of the code that will run if the condition is true. So when it's done, it will run return zero. And in this case, I had return zero instead of exit success. But again, same difference. And then, oh, we got a question. Why do we not put the semicons after the curly brackets? So the answer to that is you don't have to. So if we did, we actually could and it won't change anything. So it won't change anything. The compiler won't yell at us or anything like that. It's just a bit weird. So no one does that. It's just kind of a style choice we use because we don't need to put it there. I'll have a caveat of like dangers you can get into with just a semicolon because it's technically a statement that does nothing and generally it causes issues. So if we don't need it, we just avoid it. So, and then the question, can we put semicolon after include statements and the answer to that is a no, I believe, but we can try it and compile. Whoops, compile. Yeah, so it gives us a warning that there's some extra crap at the end. So in this case, it doesn't seem to mind it, but the compiler really, really, really, really doesn't like that we did that. Whoops. So we should probably not do that. All right, anyways, for this example, let's see. So now if I write, I don't know, an odd number, now it will print off that, hey, this is now odd. Yay, it does something different. That's kind of cool. Any questions about this? All right, I have a brain buster for you. If we've been paying attention a lot. So I just thought of this while I was preparing. So what happens if I essentially flip those two and do this? So is this program the same as what I had before? No, anyone say why not? Yep, well, let's see, let's try it out. So let's compile that and run it. So in this case, it should still work, right? So if I do eight, well, that number is even because if I do eight, mod two, the remainder zero, and then I would do zero equal equal one, which is not true, so that's false. So this would run, so it'd be this number is even. And if I do an odd number, it says this number is odd because my remainder would be zero, or my remainder would be one. So it looks almost equivalent. But this, hopefully you don't get a, if you got an exam question like this, it would be kind of mean maybe because there is a problem with this if we remember the weird mod rules from before. Oh yeah, I heard negatives. So it turns out that this doesn't work that well, if I do, is negative seven an odd or an even number? An odd number, right? Oh, yeah, this is why programming is hard because remember all those weird mod rules I went over four and it seemed like I was just yammering on for no reason. Well, I was yammering on because it might actually be an issue. So in this case, because of the mod rules, if I do negative seven, mod two, the remainder is technically by C's way of thinking about it is it's negative one. So if I wanted to write an equivalent program, what I could do is I could do num mod two is one or num mod two is equal to negative one. And in this case, if I do that, well, that should cover the negative case. So if I do negative nine, finally says this number is odd. So one way to remember that this rule is stupid is if you are seeing if a number is like an exact multiple of something, always compare it to zero. Do not try and compare it to any number other than zero. Otherwise, you have to remember the negative thing and it's just a whole hassle. So hopefully this won't actually be tested but in the real scary world out there where you have to deal with all of C's stupid little rules, then things like this may be an issue. Of course this would not be an issue if I just didn't allow negative values. So that is another option. Okay, so here is my program that will print whether or not the number is even or odd. And here I do the smart thing of just doing the modulo and then comparing it to zero because as we saw comparing it to other values, we have to remember the negative rules and generally not a good idea. So if I took the structure of this program, how it runs is well it would start running from main. So if I break it down, what will happen is this program, whenever I run it will always print, input an integer and then do the scanf so I can actually enter an integer. And then it will evaluate that expression in the if statement. So in this case, num mod two equal equal zero or sometimes we just say equals. Kind of depends on your preference there. And then if it is true, then I take this branch and I will print the number is even and then after I'm done doing all of the statements in the curly brackets in the if, then I will go to the very end and return exit success. Otherwise the only other possibility for this program right now is if this result is false, I will print off the number is odd and then I will skip to the very end whenever I'm done executing everything that runs when it is false and we have an exit success. And then yeah, we have another question. What about if we have three conditions? Can there be more if or else statements in the same group? And the answer to that is absolutely. So you can see how this quickly could make our program look like it can do a lot of different things. So here I had two possibilities I could go through. Well, I could write it so that if I go in the false statement or go in the true, I could have two other possibilities. So I could write if statements within if statements and then if I wanted to, I would have like an exponential number of possibilities that my program could follow and then you have to reason that all of them are correct and that is where software problems come into play. So generally you want to make them as simple as possible and try and reduce the number of if statements you have if at all possible. And to follow up on that question, what happens if we have multiple if statements? So I already pre-shot this. So we could write a program that does this. So input an integer, so it starts off the same. So we scan F, get an integer, and then we could have if num mod two equal equals zero then the number is even we can print off. And then afterwards we can write if the number is equal to or greater than 10, we'll just print off that the number we entered is 10 or greater. And then we can write an else after this, but this gets into a special problem where if we actually just follow the rules of C, it is not evident what else this belongs to. So does this code only execute if the number is odd or does this else right here only execute if the number is less than 10? So turns out this actually has a special name and it's called the dangling else problem. So I just have an else here. I'm not actually sure what if it is connected to. So the way C resolves this is it says this else is always connected to the first if you read up from this else. So this else is actually connected to this if. So it will only run in the case that the number is 10 or less. So if we actually run this program, let's see. So here is that same program where I have an if and then an if and then an else. So kind of told you that because of that dangling else problem, this else actually refers to this if. So if I start reading my code from the top and start arguing about it, so it'll print off input an integer, declare an integer and just initialize it to zero just in case something bad happens. And then we do a scan F. So we wait for the user to type the integer and then it will check if the user typed a even number in this case. So if num mod two equals zero, so it means I divide by two, I have zero as a remainder, means it's a multiple of two, then I will optionally print off. This is a even number and if it's an odd number I would just skip right to here. I would skip to this line if it is false. Then next thing I would execute is I would check this condition. So the number, I would check what I entered and if it is 10 or greater, while I will print off it is 10 or greater and then I will just do this return. Otherwise, if the number is not 10 or greater, then I will go into this else and then print off the number is less than 10. So if I run that, if I run this and I type the exact number 10, it should say this number is even and then the number is 10 or greater. So prints both those statements. If otherwise I type in the integer, I don't know, 11, then that is a odd number. So it would not print this line and it would skip and it would go here and then check if the number is 10 or greater and it would print that, yes indeed, 11 is 10 or greater. So I could do that with a bunch of other numbers. Let's say eight. So if I input eight, it should say this number is even and it's less than 10. So I get both of those print statements. If I instead input a seven, then I only get the number is less than 10. Then another question, what if we use the tab key to indent the group so the else statement only works on the indented group? So turns out the indentation we write for C, so if I did something, I don't know. So I think the question is like if I did something like this or I think this, but turns out C, the compiler, doesn't actually care about the indentation. It's just to make it easier for you to read as a person and yes, C does not care. Yep, so if you want, so if you just want it to, sorry, not sure of the question, like if I write another else statement. Yeah, like you want another here. Oh, like if you want to do this. Yeah, you can do that, you can pose many statements as you want there. Yep, yep. Any other questions since this is the first, you know, actual programming we've get into that's not just arithmetic. Gets more exciting from here. All right, slight murmuring. So here let's, so here's our dangling else problem. So how do we make the else statement act on both statements if that's feasible? So if I go here, if I wanted to have two else statements, whoops, then I could just do something like this. So just in this case, I'd say this number is odd in this case. So I could write something like this. So I have two if else statements. So it'll check this condition. If it's true, it runs this and then ends here. If it's fault, if this condition is false, then we'll run this and then we'll end here. And then we'll do another if statement. All right, any other questions? Yep, yep. So I can add code right here between the if and the else statement, no problem. After the if, where? It'll be else, like with code. Oh, here? Yeah. So if you write something here, that will be a compiler error. So it will say here, expected expression, because well, it's assuming that I can't just begin a line with else. It has to be connected to an if. So yeah, else by itself doesn't mean anything. So I can't have a line between the else and the if. So yeah, so else can't live by itself. It has to live with an if. All right, any other questions we have? All right, well, let us, here, let me hide this quick and see if we can come up with a game by the end of the class. So we can make a pretty decent game-ish. So here, oops. All right, so let's make a little dice game. It will be slightly silly. So let's assume that we're rolling a dice, you know, one to six, and then we as a user can place a bet on it so we can bet even or odd. And if it's even, or if we guess right, we win. And then if we guess wrong, we don't. So we went over random numbers last time. The seed can be set by the system time. So to actually do that in C, this will not be testable because it goes way beyond this course. But if I wanted to make the numbers appear random, what some things I can do is I can set the seed based on something that changes all the time. So you might not know what to actually expect to come off. So I can set the seed based off the current time so I get a different sequence of numbers every time. If I wanted to make this more secure, well, probably I set the seed off something that's a bit more random because someone actually might be able to figure this out. So if you played a game that generates random numbers, sometimes some people can break it because they'll figure out what the seed is and then they actually know what to expect. And then especially in a game like this, if you can predict the outcome, not much of a game when you win all the time. So here I set the seed based off the current system time and then I'll have enter your bet, zero for even, one for odd and then create a variable called bet and then scan F. So if I, oh, and then yeah, another question in chat, is there an if statement in C? Answer to that is no and we'll go over more complex if statements tomorrow or Monday. So in this case, if I wanted to simulate rolling a dice with my random number generator and I want to make this die value between one and six, one and six, what should I write here after RAND? So if we remember RAND before, RAND will give us just a random positive integer that's between zero and huge. So if I wanted to change that random integer instead to represent a dice rolls or something between one and six, what should I write here? Yeah, percent, oh, sorry. What does that keep, percent what? Percent max minus min plus one, yeah. So for a dice, at the end of the day, what's the answer for just a die? Okay, yeah. So if we do the math in our head, sometimes we get good. So we do percent, so mod, so mod six. So if we do RAND mod six, that will always give us a number because RAND is positive. We often deal with the stupid negative rules, always give us a number between that is either zero, all the way up to five inclusive. So if we want to go change a zero to a five, so we've got the right range. If we want to change it to a one to a six, all we do is we add one. So now we have our dice roll. And let's just, sometimes when you're developing programs, typically it's nice to just print F, print F your current value to make sure it's what you believe it should be. So let's just write here U, U rolled a percent sign D. So we want to print off an integer. So our format specifier is a percent sign D. And we end it with a new line because while that's the end of the line, we want to print to the user. Yeah, so, and then just to clarify, if I don't change the seed for RAND, I'll get the same sequence of numbers every single time I run the program. So let's compile this and I can actually show that quick too if you want. So enter your bet. So in this case, I'll just bet even and then it just says you roll the three, okay? So I run it again, you roll the four, run, oops. Run it again, you roll the two. So it seems to be different every time. So just to be sure, I can comment out that line. So when you comment out a line, the compiler just ignores it. So it's like it is not even there anymore. So if I compile and run that, I'll get you rolled a two. And because it's the same seed every time, every time I run this program, I'm going to get you rolled a two every single time. Gonna be a pretty lame game. So when I uncommented this line, so that's how we say that, then I get a random value or at least a seemingly random value every time. Oh, and yeah, this actually is an extension I use. So remember the argument names can actually have names. So you can figure out which argument is which. I have an extension VS code that tells me what the argument names are and just shows them here. So it's a bit more readable. So my code probably looks a bit different than yours. All right, so now we see our dice rolls. So now if I wanted my game to say you win or you lose, any idea is what I should write here. So I have the die, it will be one to six. So it'll be a random dice roll. So how do I know if I win? Yeah, so well, there's two possibilities here, right? I can either win or I could lose. So that probably should make you think there's some type of logic here. Sometimes I win, sometimes I lose so that should immediately make you think of an if statement. So generally it's easier to think about like the true condition first. So let's be optimistic and we can think about the winning condition first. So if I'm betting on even or odd, well, what's my winning condition? So if I can check, so if the die mod two, so that will give me essentially the remainder of the dice roll. So it'll be zero if it is even and then one if it is odd. And what I can do is actually just check if it matches my bet. So in this case, I formulated my choices just so it nicely matched with that modular remainder operator. So if I enter a bet here of zero, well, if I take that number and then get the remainder after dividing by two, if it's equal to zero, it means it's even and it means, well, my bet is the same as what I chose. So in this case, I would win, you win. And the other case, if we're being nice is I could have entered a one. So if I entered a one and the dice roll was say a three, then three mod two would just be one because it doesn't have any negative values or anything like that. So if that matches my bet, so it's odd and then I bet odd, then I also win because I guessed right. So now it can say you win. So what else should I have here if I want to tell the user they're a big fat loser? Did I hear the magical else? Yeah, so else, I don't, if I just have printf here, you are a loser, ha ha. So if I just have this and I compile this, whenever I run my game, I'll place my bet. So let's say I bet even again, rolled three. Well, I was a loser in this case, so it wasn't wrong. But sometimes when I run it, I rolled a two and then it also says you win, you are a loser, which is very confusing. It gives me an existential crisis here. So we don't want the loser text to run if we are in fact a winner. So we should put that in the else. So we should just write an else here, always do the curly brackets and we should move this printf up into the else. And because now it is within these curly brackets, each time we're in a new set of curly brackets, we should indent our code like that to just show the structure of it. So if I do that now and I compile this, we have a functioning game. So I can now bet, let's say I bet odd now. So I rolled two and in fact I am a loser. So if I go ahead, play again, let's see, odd. I rolled two, I'm a loser again, rolled six, I'm just a big fat loser. So I guess I end today as a loser. So with that said, just remember, I'm pulling for you, we're on this together.