 Hello everybody, welcome back to C++ Programming, I'm Ruder van Nel, and well in the last video we just finally created our first Hello World program. Now we're going to move into a new concept or at least kind of review some of the things that we have learned with data types and variables. So I'm going to go ahead and create a new script over here. I'll close out of the other one here. I'll save this as 02datatypes.cpp. You should do the same thing, and you can see now that exists in my folder in Cwork. Okay, I'm sure you guys remember the way that we start off our program is to include iostream so we can actually use input and output. And this time I am going to type in using namespace std for using the standard namespace. That way we wouldn't have to repeatedly have std colon colon in front of our cout whenever we output things. Now let's go ahead with our main function. Remember that always has the int type because we're always returning an exit code that may be zero if they're successful or maybe anything else if we want to tell the system any other distress signal, that sort of thing. So we've got our main function and let's use our curly braces and curly brackets for actually denoting the code block here. Okay, now let's get into variables and data types. You know up at the hop there we actually have int and that stands for integer. And we can say any variable or anything that can actually hold information or data if you guys aren't familiar with the term variable, it can vary, it can refer to anything else. There are a lot of good explanations for what a variable is online but it's pretty similar to kind of algebra if you think back to middle school or high school algebra. So let's have an int i and that can equal, we can declare, define that variable, int i can equal four. How about that? Now c++ also allows you to kind of declare a variable before you define it. We can say, okay int i simply exists. We haven't set a variable for yet but we know that we're going to be using int i later on. We can just say int i and then have our semicolon to denote the end of the line. And then we can of course supply int i is equal to four. But if we do this, actually let's just set up c out i and l in the line and I'll bring over my terminal so you can see how this will work. c++ o2 g++ g++ o2. If we say int i it'll note that, okay that was previously declared in this line int i over here. If we declare it, we cannot define it by using the keyword int one more time. So let's say int i that okay i is going to exist and then we can define i can equal four. Now if we try to compile this it'll work just fine and we can run a.out it's printing four because we know that that's the value of i. We can do this all in one step. We can say int i is equal to four like we had at the very beginning. Now if we try this that works just fine it compiles for us and we still get a.out i is going to equal four. Awesome. So there's a simple integer of course that can be zero of course that can be any negative numbers that's just an integer. Great. Remember actually let's move on before I introduce that. Let's get into Boolean values. Booleans are things that can be true or false. They're like Boolean logic. One is either yes or no. Is the sky blue? That should return true. Let's say blue or sorry Boo will be. Boo will be that can equal false and rather than in Python we don't use a capital F or a capital or capital T for true it's going to be lowercase true or lowercase false. Now if we print out b, compile this, run it zero which is false. If we set it to true compile this one because one is true and zero is false. That's the way that Boolean logic really really works. Okay cool. Now remember before I get too far ahead of myself remember that variables can only start with a letter or an underscore. They cannot start with numbers. If I were to say 2b what if I tried this? What if I tried to compile this? Nope. Oh of course I used 2b over here. Now let's try to compile this. Expected unqualified id before numeric constant. That just can't happen. We just can't have a number start the variable. It can't however be an underscore. Boo will underscore br variable. Now if I run this that compiles just fine and it's still one. Okay that works just fine for us. Let's move on to another data type. Let's move on to the char or the character. Though you can hold a single letter. We can have c and that can equal a. Now if we print out what's the value of c? Compile this. Run it. We get a because we've set that to equal that variable. Awesome. Just so you know that is the syntax. It should be char and we can have floats. Float can represent any decimal with numbers that are often have characters after the period. Float f can equal zero point blah blah blah blah blah. Now if we print out f compile this and run it. Cool. Very nice for us. There's another one. Double. Double is pretty similar to float. Let's use any number here. Double d 3.34321. Okay that works just fine for us as well. And there's also another one unsigned integers. Unsigned integers. Unsigned ints. It's unsigned space ints. Unsigned integers are only positive numbers. They cannot be negative. So if I said s equal negative 4 maybe there will be an error here. Hopefully my compiler will tell me something. Oh no yeah it's going to freak out for one thing. But if we set it to be regular 4 that works just fine for us. I guess it will compile but it will not use the value that we actually want. We can have it be signed and that sign means that it can be negative. Compile this now we get negative 4. Can we have a positive one though? Let's find out. We can. We can have 4. Sign means it could be either positive or negative. Okay so those are lots of different variable types that you will typically see in C and C++. Lots of variable types. Simple, kind of basic integers, i, booleans, characters, floating point numbers, and signed ones. You don't see these too often. Typically you'll be using with characters, booleans, or integers. That's the way things typically work. You also have short and long and these are extended or smaller versions of integers. You can research that and look it up online if you'd like. There should be plenty of documentation for C++ but we forgot our return zero line. Oh man. Keep in mind though that you can declare the variables. We cannot use the keyword afterwards after we've declared it but not defined it. So mentally kind of divide those ideas in your mind. Defining a variable and declaring a variable. Declaring a variable and defining a variable. Those are different things. Okay thanks for watching guys. This is just a simple rework for well data types and the way you can manipulate your data and your information in your program. It has to be kept track of with a specific type and you have to set that statically int or boole or character or that sort of thing. Thank you guys for watching. Simple syntax, simple stuff in C++. Hope you're enjoying this and I'll see you in the next tutorial.