Practical C++ Programming: Beginner Course | Zach Hughes | Skillshare

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Practical C++ Programming: Beginner Course

teacher avatar Zach Hughes

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

27 Lessons (4h 24m)
    • 1. Welcome

      3:27
    • 2. Installation of the Code - Blocks IDE

      6:43
    • 3. Anatomy of the Hello World Program

      8:05
    • 4. Data Types and Variables

      13:46
    • 5. Basic Output

      12:06
    • 6. Basic Input

      11:34
    • 7. Arithmetic

      9:25
    • 8. Concatenation

      5:02
    • 9. If Statements

      13:56
    • 10. Switch Statements

      8:03
    • 11. Practical Program #1

      12:31
    • 12. While and Do-While Loops

      8:13
    • 13. For Loops

      6:50
    • 14. Data Structures - Arrays

      9:32
    • 15. File Output

      6:46
    • 16. File Input

      15:26
    • 17. Advanced Input and Output Manipulation

      12:05
    • 18. Practical Program #2

      16:59
    • 19. Functions

      7:01
    • 20. Parameters

      4:57
    • 21. Pass by Reference

      9:54
    • 22. Function Overloading

      8:22
    • 23. String Functions

      3:33
    • 24. Random Number Generator

      6:51
    • 25. Project -Hangman (Part #1)

      18:16
    • 26. Project -Hangman (Part #2)

      15:54
    • 27. Project -Hangman (Part #3)

      8:34
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

2,088

Students

1

Project

About This Class

C++ is one of the most used programming languages. It is an object-oriented language, offering you the utmost control over interface, resource allocation and data usage.
This class covers the basics of programming in C++.  Created for the beginner programmer, this class requires no prior knowledge of programming. The main aspects of the language are  introduced in a logical, gradient manner with a step by step approach.  This will provide you with a solid foundation for writing useful, correct, maintainable, and effective code. 
By the end of this class you’ll have all the skills you need to start programming in C++. With this complete class, you’ll quickly learn the basics, and then move on to more advanced concepts. 

Meet Your Teacher

Teacher Profile Image

Zach Hughes

Teacher

Class Ratings

Expectations Met?
    Exceeded!
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Welcome: Hello. Welcome to Practical C Plus plus programming the beginner course. My name is Zak and I will be your instructor. Now, before we get started with this, syllabus might go ahead and tell you a little bit about myself and some of my credentials. I am currently a student at Carleton University, where I am on my way to earn a bachelor's degree in computer science and a miner's and associates degree in electrical engineering. My electrical engineering Associates degree is actually coming from a community calling in my area, and I do live in Texas if you couldn't tell by my accent. So I hope that doesn't bother you too much, but I'll try not to make it sound too Texan when I'm recording My background in programming involves a heavy use and heavy practice of C plus plus. I've taken many semesters and C plus plus at my university. I have actually taken three semesters in C plus plus total, and I've taken a semester in Matt Lab and engineering programming language and I, currently on the side programming Java for Android application development, and I've actually developed my own angel. Would applications for the Google play store. So that me and said, That's enough about me. Let's go ahead and look at what we're going to learning for this course. So if you look on screen, I've kind of listed everything that we will be for sure going over in this class. But just remember that the class is not limited to this syllabus. So there's gonna be things in between these these concepts right here that we will be going over, you know. So everything you see on screen is is not everything that you will learn. You will actually learn much more than just everything you see here. So, you know, if you're a complete beginner in programming, I would say that this course is definitely the perfect course for you because I'm not going to start with just the C plus plus principles. I'm going to actually introduce the basic programming principles in general to start the course off. So if you don't know anything about data tops and variables were actually going to cover that right at the beginning, of course. And then we're gonna move on to how to use these program and concepts in C plus plus and develop her own useful applications. And when I say useful, you know the course is called practical C plus plus programming. And that's because I think the C plus plus is a much fun or language to learn when you're using get in practical situations. So that's exactly what we're gonna do. We're going to develop a small business application, a simple calculator app and then at the very end of the course for a final project, we're going to develop a hangman game that you can show all your friends. And hopefully, if I get enough students for this course and enough people leave good reviews and tell me that they want to see an advanced course than that's then that's what we're gonna do. I'm actually going to make an advance C++ course. After this, we're going to object, wearing the design and everything like that. So stay tuned for this Siri's and I'm glad you're part of the course. Let's get started 2. Installation of the Code - Blocks IDE: Hello, everyone. My name is Zak and I'm here with practical C plus plus the beginner course. And in this tutorial, we will be going over the installation of the code blocks. I D e um I d e stand for interactive development environment. And ah, we will be using code blocks as our i d. For this entire course, our chose code box. Because, as I said in the introduction, it's actual what ice began not only learning c plus plus in but programming in general. So, uh, not only I mean that, but it's also free. So have fun is a really good choice to begin your programming. Um, you know your your programming going. So as you can see, I have a Web browser open. And if you go to Google on top in the search, more just code blocks. As so, um, the first link you will see is www dot code blocks dot work. And this is where you're gonna want Tokyo. You can either click on this first code blocks link and then click on downloads. Or you can do a common. Do you just click on the downloads link below when the page loads, You know, depending on my on how my Internet is ah, doing right now. But when the page does load, you're gonna be brought here and you will have several links. Like download the binary release, download the source code and that retrieve source code from SV end. You are going to want to click on download the binary release. They will bring you to this page. Now, depending on what operating system you're on, you're going to click on something different than I may be clicking on. You know, if you're on Lennix 32 bit or Lennox 64 bit, we're gonna be looking at these boxes right here from Mac OS X ray gun one scroll the way the bottom and they have a download link right here. Um, me, though I'm on windows seven. Salt will come up here. And if you look, it doesn't say Windows eight right here. But up here it says windows, you know, seven dash A. So these Ah, these binary builds should work on Windows eight neigh 80.1. In fact, I've actually downloaded on Windows eight and eight point warning, So I know for a fact that will work. If you look over here, there are two different links. There's burly OS and source forge dot net. I'm not that familiar with burly OS, Um, but I am familiar with source for it, and I use it for a lot of my downloads, so I would recommend using source foraged dot net. Now there are three different, um, types of binary releases that you can download now. When I first started, programming mind structure had us download this binary released right here. The 2nd 1 on the list, which is perfectly fine, works great. Um, but as I got in a more advanced C plus plus programming where I'll start doing concurrent threads and you know, different kind of ah, concurrent thread processing, multi threaded processing, I needed this GCC 4.8 point one for my co box toe work with threads. It's a specific compiler, so I would recommend if you plan on going Maurin debts with C plus plus and maybe taking a course after this to go ahead and download this one. Because if you start getting into threads and C plus plus, you will have to come back and download this compiler right here for toad blocks work. Um, otherwise, you know, this right here is a great auction is will. So either one is fine for this course, Um, you're gonna want to go ahead and click on source forge dot net to continue on either one of links and my click on the 2nd 1 It will take you to source foraged dot net and the countdown will begin for your download. And after the countdown, the XY foul should be downloaded. We'll give it a second, and right down here, you can see code blocks 13.1 point two Dottie XY, and, ah, it says they're still, you know, non 10 minutes left before it's done downloading on mind. So it might take a while for it to download. Um, I'm not going to sit through this tutorial on wait for it finished downloading simply because I already have it downloaded on my computer. But I will tell you when it does finish downloading, you're gonna want to launch the XY file, and a install wizard will pop up. And it's very simple. Install wizard. Basically, just click next on every single pop up window and it should install very easily with no problems. After it's done installing, you're gonna want to search for the program either by using your search like this, or it might have even put it in your task. Four like I have it right here. And it might even have a desktop shortcut. Whatever the case, you're gonna wanna launch code blocks, give it a little bit of time, especially on the first time launching it when the first time you launch it, it might take a little bit longer than you expect. Also, though, it seems like it's taken a while for it to download on my computer. My Internet connection is quite slow right now. I just moved, and ah, I have slow download speed as a right now because I haven't yet upgraded my Internet so that it's on your at your, you know, at your house. It might. It will probably go a lot faster than mine. I think I have, like, eight megabits download speed right now. This is what's going to pop up when code blocks launches and ah, in the next tutorial, we are going to create a new project and ah, we will discuss the hello world project that will be created and discuss the anatomy, uh, the our very first C plus plus program. So stay tuned, and I'll see you in the next tutorial. 3. Anatomy of the Hello World Program: Hello, everyone. Welcome to practical C plus plus beginner course. I'm Zak. And in this tutorial, we will be going over the hello world program. So if you open up code blocks, you're gonna want to click on, create a new project and then click on console application. Ah mahn, it's in the top right corner of the window on yours. It may be different, but you want to click on console application and then hit. Go then on the next window. You want to hit next until you get here, make sure you highlight C plus plus click next again and then give your project and name in mind. I'm just gonna call it tutorial wine and then specify folder to keep it in. Make sure it's a folder that you confined easily and then quit. Next, Leave all the default settings on this window right here. These air simply ah, direct directory and compiler settings Just hit finish and then your project is created. So right now you don't see anything. But if you go over here to the left and click on sources, you'll see the main dot CPP file, which stands for main dot C plus plus, and if you double click it, you'll see the code. Now, before we analyze this code, I want to go ahead and show you how to run it and what this code does. And to do that on Windows you can either hit F nine or if you're on a Mac or Lennox machine . You just go up here and hit, build and build and run. The code will compile, and then you'll see this console window. It prints the word hello world and then says process returned. Zero. Okay, so you can close out of this Now that we know what the code does, we're gonna look at how this code does what it does. Um, so beginning with kind of the main thing I want to show you in this tutorial other than you know how to run your first program and compile it is you know how to type out the skeleton of a C plus plus program. It's what I call the skeleton. And it's everything that you need Ah, for your code to rind, at least in this course anyways, for every program that we will be riding together. So if we go ahead I want to go ahead and take out this line because this line is not actually needed for this program to compile and Ryan. So if we take it out and we hit F nine and we build and run it again, we will get the process returned to zero. We just won't have hello world printed to the console, which means, I mean, that's fine. The program just ran and executed till it finished with no heirs, and it's a perfectly good program. So if we exit out of this, we're gonna now analyze everything that we need, which is everything that you see right here. It's a starting from the top you're going to see pound include Io stream. This line of code right here just simply tells the programme that it needs to include a C plus plus library known as I O Stream, which stands for input output stream. Now, on every program that we write, you will need this line of code, which is why I include it in our skeleton is because, you know, if you don't have this line of code, your program will lose its basic input and output functionality. So you do need this line of code and every program that we right moving on, you're gonna see using names based standard. Now, this line of code is not necessary for your program to rind. Okay, so if we took this code out right now, it should still run. Fine. We hit f non, everything goes fine and we still get the same result process returned to zero. However, I do want this lot of code in here for reasons I'll explain in the future For now. Just know that we do want to include it as part of our skeleton because it will make your life easier when we start riding more code and I will show you why in future tutorials. But for now, just know that you do need using name, space standard semi colon. Okay? And it doesn't with the cynical and I know right now you're saying, why does this line of code in with Semi Colon and this one doesn't? Well, we'll get to that in future tutorials again. It's all gonna become a habit for now. Just know this. This is the code that you will need in all of our C plus plus programs moving on to the next big chunk of code. This right here is known as your main function. And in every C plus plus program that we write, you will need a main function and type it up. You just simply right I into you extends for integer and then Maine open prints, sees close parentheses and then your brackets. What the return zero statement now and programming. There's two different conventions for writing these brackets. I'm gonna go ahead and show them to you now so you don't get confused later. If I do this one, convention is the way just saw it, which is like this where your brackets are open and closed down here. But the other way, you may see it is like this where your brackets opened at the top and closed down there, which is fine. There's no, um, difference in the code whatsoever. It will run just the same, so just know that it's ah, it's just a program and convention. There's no right or wrong way. Some people have their own opinions on why they do it a certain way, but just know, you know, it's all a matter of preference so before we in this tutorial, I want you go through and I want you to top this up with me so you can get in the habit of doing it. So what's the first thing we need to do? What we need to include the input output strings C plus plus library so that we can, you know, output stuff to the console window. To do that, we're going to hit pound, include i O Stream. Okay, No semi colon on this line again. We'll get in the habit of knowing where to put him when we're not to put him. But for now, you know, just know there's no cynical And at the end of this line now, though, we don't need it for this program You do want as part of your skeleton for this class. I do want you to get in the habit of riding, getting all of our programs. So let's go ahead and do it now. You want to use the standard name space and how do we do that? Remember, we topped using name Space Standard, and that one did have a cynical moving on them. Other really critical piece of code that we need for our program to run is the main function. And remember, that was proceeded with I and T. You extend for integer the name of the function main open princes, close parentheses and then our brackets, depending on what convention you decide to use will be different and then returned the value zero. This right here is working code. If you take out some of this code, such is that this code will return in air. It will not run. So for now, just know that everything in this code is needed. And in future tutorials, we will go into a discussion as to why they're needed and what exactly, they dio. But for now, let's move on to the next tutorial where we will be discussing data types and variables. Thank you. 4. Data Types and Variables: Hello, everyone. Welcome to practical C Plus plus the beginner course. I'm Zak. And in this tutorial, we will be discussing data types and variables before we get into the code blocks editor. I kind of wanna do this on a, um I'm no pad sheet real quick so that weaken we can show you. I want to kind discuss with you how these data types are declared and what they mean. So, a dead a type. What is the data type? What is a data type? Um, a data type is basically a description of what we are using. So, for instance, and the real world, um, if we were gonna use the this the letter B, for instance. Well, this is to us is known as a letter. This would be the data type in programming. Okay. Or what if we were talking about the number seven on our world? This is just called a number. This again is a data type. And, uh, you know, if we were talking about programming except in programming and in C plus plus, we don't call them letters and numbers. So how do what do we call them? Well, let's start with just a single letter. Let's let's to start with the character. Be okay again. This is just a letter, but in programming, this is called a character data type and the character data type. Sorry about that. The character data type is denoted or, um, kind of encapsulated with single quotation marks as so So That's how so and C plus place this letter B. It's called character data, and you have to declare it with single quotation marks. And when we get into example code you'll you'll understand what I mean by declare with single quotation marks. But let's move on to a number. So let's say seven and C plus Plus. This is called an integer, and an integer is denoted just as it seemed. No quotation marks, nothing special. What about multiple letters? So you know what? What about? You know, the name Bill? You know, that's that's four characters. But this thing is a whole What is it? Is that a word? You know, in our world, it's called a word, but, uh, what is it? What is it in C plus plus well in C plus plus, it is known as a string, which is Alfa numeric data. Okay, but for now, just know it's called a string data. And he did note string data with double quotation marks as so okay. And I kind of want to go over one last thing. Ah, and that's decimal numbers to, like, seven point 77 you know, Is that an integer? Well, no, it's not. It's not a whole number. So what is that called? Well, in this, it could be one of two things you know, actually could be multiple things, but for this course, we're gonna keep it simple. Know that it's either a float or a double. Okay? And it's denoted just as 7.77 for this class. We're going to use the word double on the reason why is because if you use the word float when you declare it as this 7.77 behind the scenes and code blocks code blocks automatically and converts it to a double anyways, so for now, we're just gonna call it a double data type. Okay, so let's move on to some actual code, okay? And we're gonna practice declaring these four major data types that I've shown you here So let's open up our code. And by the way, in the last tutorial, the code was a zoomed in. If you couldn't tell if it was hard for you to read in the last tutorial, Um, hopefully this will make it easier for you to read. Um, so right now, let's go ahead and practice what we learned in the last tutorial in this project. On a practice riding our skeleton, so to speak, everything we need for our code. Right. So we need to do basic input and output library. We need to include it. So lets include Io stream. Okay. We want to use the standard name space. Okay. And then we need to declare our main function. And we need a return value for this main function, which, as we said, we're gonna use zero. And this is our skeleton. This is everything we learned in the last tutorial again. If you If this isn't if you still haven't got this down yet, you know, she suggests his practice and get over and over until you get it down to where you can basically do right this code in your sleep to get your program to compile and rind, as with process returned zero. Let's get into our data types and variables. Okay, so we discussed. How do you know what the data types were? You know, it's kind of a description of what you're dealing with, but what's a variable? Well, a variable. It is kind of like a box. And your data type is a label on that box. That's how I want you picture this. So you have a box, and then you have a label on this box. Okay, so So let's say we put the letter B inside of box. Okay, So the letter B is character data, right? We discussed this earlier, so to declare the character data, we write C h a r, which stands for character. Okay, so that's our label character. C h a R. That we're putting on her box in our box is user to find meaning we can name it, whatever we want. So I'm going to name it, um, letter, because that's what's in this box is letter. It's a letter. OK, And then we need to declare what the letter is. We put a equal sign. I'm sorry about that. Guys don't know what that is popping up. They put me in equal sign. Okay? And then again, character data is denoted with single quotation marks. And then inside the single quotation marks, we put our letter be and then end the statement with a semi colon. And this right here is declaring a variable. What? The data type of character and that variable that character variable this letter B. Okay, so let's move on. Let's let's let's move on to the other. Now, if you don't know what this is used for yet, that's fine. In the next tutorial, we're gonna discuss how we use these variables and what exactly they're used for. But for now, we're just declaring them, and I'm kind of giving you a visual ization of what they are. Okay, so just for now, think of them is a A box with a label and then something inside the box. In this case, it's a box that holds characters and in the box is the character be okay? So let's move on to a number of box that holds numbers. So again, a number is gonna be an indicator if it's a whole number, so to declare a whole number integer value. We write the word I m t which he makes. You probably remember from here in Maine, which will get into why you need that again in future tutorials. But for now, let's focus on this, and we're gonna put a number in here. So let's call this variable number again. It's user to find. If I wanted to call it Jimmy, I could call it Jimmy. But you gotta want it. You know, it's convention to call it something that represents So we're gonna call it a number, and that's gonna equal with number seven and you end that with a semicolon. Remember, No quotation mark. Try here. Just the number. Okay, so that's That's another variable. Let's do the other two variables we did. Let's dio a, uh let's make a variable that holds the name Bill inside. So to do that, we write string because that's the data type. Remember, multiple letters is Alfa Alfa Numeric data is called string data. Okay, which you know I'll actually get into it later. String is technically a class, and I know you don't know what classes. So for now, just know it's it is a data type for now. Okay, string data we're gonna call it Name equals double quotation marks. Still semi colon. Okay, so there's your variable for a name or multi character data. OK, now and string don't don't get it confused with, um Onley being characters if I want to do Bill 99. Hyphen, hyphen, hyphen. Cynical on semi colon Inside these quotation marks, that's fine. Alphanumeric data will hold all these characters, and this will not cause an air. This is everything you can keep in this variable that is find. So I just know that, but for now, actually, let's call it Bill 99. Okay? So that you you don't forget that you can actually put numbers and string. If you wanted to do just 99. You could as long as you have the double quotation marks. It's still string data her case. But for now, it's Bill 99. And then for the last data type. Let's do a decimal number, Ricks. Remember? I said it could be flow or double, but for this class, we're going to use double, so it's a double. Let's call it decimal equals 7.7 seven. Cynical and all this is fine. If we run this program, it will not cause any heirs. Everything runs, process returns zero. Same outcome. All this stuff is happening behind the scenes. So of course you won't see anything in the console window when we run it. Anything different, you know, you'll still get the same result process returned. Zero Everything's fine. But the point is to just show you how to declare these variables and data types kind of discuss what they are, and, um, show that, you know, if you if you declare them right, you won't get a nadir, let me show you what will happen if you if you know if you call this character or let's say we call it, um, string okay, without the double quotation marks if you declare it wrong, which this is declared wrong because you're calling it a string and you don't have your double quotation marks. If you wanted to be right, you'd have to put in double quotation marks. But if you take those out, then this is declared wrong. When you try to build and run, we'll get an air, See this red box, And if you look down here in the log, you can scroll down and it says air conversion from double to non scaler. Top standard Colin Colin string requested. And that build failed one air. So they're right there will cause the program to crash. So when you change that back Teoh double. If we run it again building rind, everything will go fine. So that's it for this tutorial. Um, let's move on to the next tutorial and ah, we will learn about, um, input and output and ah, continue on after that some basic arithmetic and some more fun stuff. So thank you for watching. 5. Basic Output: Hello, everyone. Welcome to practical C plus plus for beginners. My name is Zak. And in this tutorial, we're going to be discussing basic input and output, and we will be using the stuff we learned in the previous tutorials to do. So, um, as you can see on screen, I've already got our, uh, basic code typed up. What we've been calling the skeleton. Do you need to add a return statement? Return zero, and ah, for this tutorial. You know, I kind of wanna I want to go into We're gonna start with output because I'll put it's going to be a little bit. We've kind of already seen it in the hello World program. So in the hello world program, we saw something along the lines of this. And when we ran it, the screen printed hello world before we saw her process return to zero. Okay, so for now, we're gonna go ahead and take out this end. L right here, because I just want to focus on something a little bit easier, and that's just basic output. And then we're going to basic input. So right now we're just going to see, um this right here hello world, and when we run it, you'll see a little bit of difference, but not much. The only difference is there's not much space here. It says Hello world, And then immediately process returned zero and later we'll get into Why that so when we took out that last code, But for now, let's just leave it as is. So So what is this? Well, this is an output stream. See out. That's where the out comes from, is output. So when you see out, you're referring to output to the console, and that's what the C stands for console output, and the console is the big black window that pops up when we were on our program. So when we say Consul Output and then these two operators right here and then we specify a string and this is a stream because there's double quotation marks, we specify. Hello, world. Um, the console will actually out plate the word hello world, and that's exactly what happens. Okay, so, you know, kind of just to show you we can play integer. We can put an integer here if we want to. We could say I'll put um nine and, ah, it'll output the number nine on the console. Okay, so that's kind of basic output. Um, but I kind of want to go into all come one throwing variables into this for a second. So the previous tutorial we discussed, you know, the variable letter. You know, we will call it the letter Z this time. Okay, So for one toe to declare a data type of one character and we want that character to be the letter z, we would do it as we specify C h a r character, and then we'll call it. You know, we're calling anything we want. We'll call it, You know, we can call it Ah, letter Z, um, equals And in single quotation marks, Z semi colon. So here's our variable right here. Well, if we wanted to output this variable, we would just say, see out operators, and then we re type the name of our variable letter Z. And if we run this, we'll get what you expect. We get the single characters e because what this is saying? This is saying, consul output, the variable letters E, which we call letters e. Okay, um, output, whatever this variable is holding and it's holding this letter and remember it just cause we called it letters. E Let's let's call it something else. Let's call it. Um, Let's just call it box. Okay? Let's say we called this box, okay? When we see out box, it's gonna go toe where we declared box at, which is right here the variable box. It's gonna look. What? What? It's holding what's holding a character Z. So when we consul output box, it outputs Z to the screen and the process returned to zero. Now let's back up for a second because I didn't really explain this. What are these right here? Well, these work hall ish Icahn stream operators there basically they're just the output stream and what it is is any time you say, see out, you're wanting to out. But you can't just say see, outbox, that we're returning air right there. That's an air. So what you do is use a output stream operator, which is just to less than in signs. So you have to say, see out to Leslie in signs Not this. That has to be to s and signs and then box. And if we do, I can. I just want to show you know more for practice. I really want you to do this on your own so you can see all the different possibilities. But if we do to these lines of code right after the other, you're gonna get just that you're gonna get to disease one after the other. Okay, so I got twosies because we wrote statement twice. So that means said, let's let's try something Here s O. So let's go into that right here in Del. What is that? Well, that stands for end line. And this is used a lot with basic output because it gives you spacing. So if we do output stream operator, which basically this is the same thing, it's saying, See outbox council output, end line. This will work the same way Z and then you'll see there's a space here because we added a blank line and if we do so, we could take this out. We can even add it right here. This is the same thing. We just did that. We're using it all in one line of code. Basically, you're gonna get the same exact results. I kind of wanted to show you that there's many ways you can do this. And I really want you to play with this on their own because you're gonna learn, you know, you you could say see outbox, um, en del box in Del. And then when you run it, you get just that you get a Z than on the next on Z and then a new lon. But if you know if you add another Z, you it gives you got there. So says Kind of you really just need play with this output because you're gonna get a lot of cool stuff. Let's move on below this. Let's leave that code there. Let's let's declare a new data type. Let's call it Let's do am a decimal about you. So remember, Double, we'll call it. Um, Box two. The variable name equals 89.47 semi colon groups semi colon. So that's our second variable. So let's had see out Box two in Del and let's run that. So what do you get? Will you get your twosies? Because he had box here, you ended the line On the next line, you put another box and you ended the lawn and then on the next line you put in Box two or what's in box to 89.47 That's why you 89.47 Then you ended the line and then you return zero process return zero So you can see if you play with this, you're gonna learn and you and I want you to do it. I want you to go through. I want you use different data types. Um, you know this this right now if we just did Ah, let's try another data type just before before we in this tutorial. Let's dio the string and we'll call a string Um, address equals 1400 College drive. That's an actress. And we had to use string because it's alphanumeric data, right? You know, if we wanted use, we couldn't use an integer because it obviously has Alfa characters in it, too. That's why we used string for the address. Variable. If we wanted Teoh, I'll put that you know, we could do you see out. We'll give it some space will do to new lines and then we'll say output address and then at another new on end line. Let's help put that. Let's see what that looks side. So we get our twosies, or box to variable 89.47 And if you look down here, we added two new lines. That's where the blank space comes in. And then we output in the address. Oops. So then we output address 1400 college drive, which we declared in this string variable right here. That's where that comes from, and then process return to zero. So there you go. I want you play with this when you try doing it with character data into your data string data and, um, double decimal point data. Alex, you practice out putting everything that we learned here, you know, maybe try ah, out putting your name and writing a sentence, you know, like, maybe try doing, you know, string name equals and then put your name. So my name is Zak and then try to output that So be, like, so in the line. And then output name and then output, um, is teaching a class okay. And then in the ill in the line. And then I'll put that and look at what you're gonna get you're going to get really, really cool output because you're getting a name that you declared in this variable string name. And you in that variable you're declaring it is the name Zack, which is output right here. So you're saying, um, you know, Consul Output, my name, which we declared here, Zack. And then immediately after that, don't in the line or anything. You know, output. This string that we're declaring as a raw string right here. This isn't an invariable. This is actually we're just putting this Straighten Your output stream is teaching a class and then in the line and look at everything. Look at all the cool stuff you can do with that. You'll surprise yourself. You know, I just really want your practice that originally we were going to do both input and output in this video. But we're gonna save input for the next video, I guess. You know, I really want you to practice this right now, declaring your variables, writing everything up and seeing how you can output different things to the stream on your own. But for now, that's all there is to this video. And I'll see you in the next tutorial. 6. Basic Input: Hello, everyone. Welcome, Teoh Practical C plus plus for beginners. My name is Zak, and in this tutorial, we will be going over basic input. So in the last tutorial, we discussed basic output. We discuss things such as, you know, if we declared a string with, um you know, we'll call it name equals Zach. And then we would declare, You know what? Let's say an integer value age equals 23. And then let's say we we wanted to output that, you know, we could say something like console output. See out the two less and signs, you know, don't forget that. And then we could say name to a saint signs and then is that's gonna be a raw string that were in putting into this ALPA stream right here. Then let's say I'm less than age. Let's say in less than years old and then we'll even throw in a new on end line out there when we printed that, you know, if you messed around with this enough. Oops. So you saw on air out there? I'm getting an air, and the reason lies because I wasn't paying attention, and I'm sure you caught it is You were watching me, but this right here is an integer, and I accidentally put in double quotation marks. So it's let's take Weathers. Double quotation marks turned this into an insecure. There we go. So now we shouldn't get an air. Whenever we build and run this someone build and run, it no airs, and we get the output. Zack, it's 23 years old, and, uh, if you practice this enough, this should seem pretty, uh, pretty easy for you to understand. Bullet. Let's let's move on to what we're talking about now. And that that is input console input. So, yes, if council output ISS see out. And what do you think Consul in played in is? Well, that's gonna be CNN, okay. And then see out deals with less and less than well, CNN deals with greater than greater than. Let's if you look at the difference between these two the stream operators and right now I know you're thinking, Wow, I'm going to get those mixed up a lot. Well, well, believe me, I got a mixed up all the time when I first started programming c++. But I promise you, after lots of practice, you will probably never, ever get a mixed up again because you'll get so used to using the right wine. And, uh, this is gonna have to be something that you practice a lot, though, because it's not something that you can get now and you know, immediately. So you have to remember seeing is greater than greater than see, how is less saying less than operator. So how do we you see? And, you know, console input? Well, if you're asking, let's take this out real quick, okay? Actually, no. Let let's leave this up here, okay? Let's just give us a little bit more space. Give us another new line and then let let's do at another name. Let's declare another variable. We'll call it String. Name two, and we won't. We won't. Uh, We won't give it an actual name. See how we have it appear we haven't declared as a Zack. We declared name. Is that right? Here were declining name, too. Is nothing named to isn't holding anything right now. And so what we can do is we can say something like we're gonna output enter name to. So what we're gonna do is basically we're gonna have Zach is 23 years old, output and then blow that. We're gonna get an output saying Inter name too. Well, it's asking for you to enter something. So to enter something and toe, let the user use the keyboard to type in a value u CN greater than greater than and then the variable name that you want to hold the employees in. So since we're telling them to intra name, we're gonna use this variable to hold the name that they enter. So let's say seeing greater than greater than name to and what that's going to new is when the when the user enters and a name, it's going to store whatever he enters into the variable name, too. Okay. And then we can say, see out, we're gonna end a few lines. We're gonna say you entered and then name, too, En Del, What this is going to do is whatever I enter and for this right here seeing name, too. It's gonna output you entered. And then whatever name too is holding at that point. So let's test it. Let real quick. Let's build and run this. So if you see we get. Zach is 23 years old. That is the result of this first declaration and output stream that we have going on in this first part of code that we did it beginning. But then it says Inter name, too. And you see a cursor blinking right here that shows that the consoles waiting for input. So right now, we're right here in the code seeing name, too. So it's saying Inter name, too, and the consul's waiting for us to input something. And whatever we input, it's gonna story into name, too. Okay, so if we enter, let's say Jimmy right here and I hit. Enter. They'll say you entered Jimmy because right here we consul output you entered in the name to and Name two is holding the value that we entered into. And that's where it says you entered Jimmy. So what happens if we want to do something like it age to you? Well, then, obviously, since we're declaring age two is an integer whenever we ask for input. Oops. I forgot to change this to age, to build and run it again. And then, of course, shot here. This needs to be H T. That's where these aiders are popping up, so fix that. Let's run it again. So it's asking Inter age too Well. Age, we declared, isn't integers. Obviously we need to enter an integer such as eight. I'll say you entered eight. What happens if we enter a character data Instead? I could be Were beat 39. That string data we'll send you entered zero because basically what's happening is is that's not a validated type. So it's giving us a garbage value right here. So any time you get a weird value, that's not what you're expecting. You not want to go look at your data types that you've declared and make sure that their matching the input of the user. So what I want you do is I want you to practice using the CNN Council input and maybe make you a little script or something, a little program that asks you what your name is and practice entering it in with different data types. You know, for instance, you could declare, you know, can't do first initial the character last initial and then say see, you know, Consul output, enter first initial, then you're going to a consul. Input first initial and then see out and then maybe give yourself some space with some in Dell's in lines and say, you know, enter second initial, and then you're gonna have to do another consul input, seeing greater than greater than last an issue initial and then say see out and then give yourself some space and say you know something along the lines of you know your initials are. And then first initial last initial. Then if you run that I will say in her first initial, the inner second initial are your first. Your initials rz are just kind of practice doing something like that, you know, entering different data and make sure you're declaring your data tops, right? And, uh, make sure you can do mix your input and output and get everything right. You know, practice using the stream operators because, you know, seeing is using greater than greater than and see out as usual left saying less. Man, I would say, Take a few hours, you know, practicing this and, uh, just doing different scenarios, you know, do your initials, a program that's for initials, and then do one that may be asked for your address and stuff like that and just practice entering in data and I'm action. Get with your data types. And in the next video, we're gonna We're gonna actually do something a little bit more practical. We're gonna use arithmetic. And then after that, Ah, you know, after we get the math down, we're gonna right, you're gonna make a calculator or something. So I look forward to that. I'll see you in the next tutorial. 7. Arithmetic: Hello, everyone. Welcome to practical C plus plus the beginner course. My name is Zak. And in this tutorial, we will be discussing arithmetic, which is all your basic math functionality in a C plus plus program. So to start off, I'm gonna go ahead and assume that all of you have been practicing declaring your variables and what not? Uh, so I'm not I'm not going to explain that stuff in debt time. I assume you already have this stuff down. So to begin, we're gonna start with simple addition and subtraction, and I just want you to follow along, and you should notice that it's fairly straightforward. So you could start by declaring your variable as so And then if to use these two variables and her arithmetic, you know, operation, you could do several things. You know, you could hold you could declare variable called result and hold the arithmetic value of the addition of numb one. Plus numb to know that will hold the value of this operation. So if we wanted to actually output that we could see what the value is after this operation , and you should see that it's 11 as so in the same thing if we wanted to do subtraction. You know, you just add a minus sign of hyphen, and when you put that, you should get negative. One negative went so you can see that in C plus plus addition of subtraction are fairly straightforward. And I do want to show you a few things you know, with respect to hard coating value. So if we want to do number one minus four, we can do that. We can hard code the value in there and C plus plus that's Bond will get one. And I also want to show you another outplayed trick. If we wanted to just output the result of numb one plus numb to we can do that, we can output. That result will get 11. So there's lots different things you can do with addition and subtraction and all your basic order of operations rules do apply here. So if we went to output, you know, number one plus numb to, you know, minus four, that's gonna It's gonna do the order of operations to do this so it's going to start in parentheses. Do this operation here that will result in 11 and then subtract four to give you seven. And we're just gonna output that all once and we get seven as so. So when you play went around with the addition and subtraction and you'll find it's fairly easy and that there's lots stuff you can do with it with respect to output in order of operations and hard coating values, etcetera. But let's move on to multiplication and division. Okay, So same thing with multiplication division, we're just gonna go ahead and put the whole operation in this output stream right here. So we're gonna see out number one and then for multiplication. It's not an X, as some of you may think, that section Asterix so number one times numb to which will give us 30 in this operation and we all put, we get 30. Multiplication is fairly easy. And you know I can set Order of operations again applies here. So if we went to put that there and then plus seven, we should get 37. And I do believe if you you know, if you if you remember this stuff from math class, you don't even have to have these parentheses here for this operation because multiplication will come before. Addition, Multiplication division first and then addition and subtraction come after that. So if we run that, we will still get 37 you know? So it's different. It's not gonna do no more implicit. You know, if we even put just to kind of prove to you if we put seven plus num wine, it's still going to do this operation first and then add seven. We'll get 37. So I just kind of wanna show the importance of order of operations and c++ because the rules still do apply. So let's do something like this. Let's let's change number 22 30 Okay? And let's let's cross some division and division you would just do numb to. And then the backslash is the division sign number one. And if this works rise could be 30 divided by five and it's gonna output six. That's fairly simple right there. And you could do the same thing again. Order of operations. You know, if I wanted to ad to to this will get eight, no matter where I put it. You know, I can't put it in between here because if I do something lets out do something like this. It's audio, you know, Numb one divided by five plus numb one that's gonna be It's gonna basically do this first. Actually, let's do this. You know, this is a cool order of operations, because here you have addition. But you have division first, so you might say, Well, division's gonna go first. Well, that's not true, because parentheses goes before multiplication and division. So here is going to do this operation 1st 5 plus Numb Boyne. So that's gonna turn into 10 and then it's going to the divisions. So 30 divided by 10 and it should output the number three. If we run that, that's exactly what we're gonna get. We're gonna get three. So this stuff, if you practice it enough, it's gonna become fairly straightforward. And you're gonna realize you could do a lot of cool stuff with this arithmetic operations. So one more main arithmetic operations on my show you is the module ist operator, which is the percent sign on the keyboard and what This days, this returns a remainder value from a division operation. So just to kind of show you, we're going to change number 2 to 11 and leave number one in five. And we're gonna hold. Result equals numb to module its operator NUM wine. Now, I want you to think about this. This right here. This operator is basically returning the value toe hold in result of the remainder of the division operation. And if we divide numb to buy numb wine, basically, we're gonna get 11. Divided by 55 will go into 11 2 times, with one being the remainder. So this operation will store the number one into results. And if we output result, you'll see. Oops. Hold on one second. If we output results, I think I hit the wrong key. Yeah, here we go. We get wine, which is the remainder. I kind of want to show you that. You know, if we do also, you know all the rules apply. You know you can do. I mean, I'm sure this becomes fairly clear to you, but you could do result plus four right here. See our result plus four. You know, you can you do That's going to do five. I just can't wait to show you that real quick. Okay. And, ah, going back to the module ist operator, you know, let's do another. How about let's do this? Let's let's do to modelo operators in a row. So let's do just so you can kind of see if you can guess what the value will be after this operation. Let's do the value. 14 here and let's output result module its operator Margallo. Whatever you wanna call it, Result module. Oh, let's do to you. Okay, so think about this. Results is holding the remainder of this operation, and then we're out putting the remainder of this operation. So think about that for a second. Now, I want you to try to guess without puts Gonna be. Now, if you guess 20 you're correct. Because what's happening is result is holding none to divide about number one and the remainder, which is going to be four. Okay, because five or go into 14 2 times with four left over, and then we're gonna output four divided by two in the remainder of that, Whether there isn't a remainder of four, divide by two, it zero because two goes into four evenly. So when we output this, we're going to get zero, and it's that easy. So that means said, that's all for arithmetic for this tutorial. And in the next tutorial, I'm not going to something called Concatenation, which is sort of like addition with strings. And ah, you will find that pretty interesting, too, I'm sure. So I'll see you in the next tutorial and thank you for watching. 8. Concatenation: Hello, everyone. Welcome to practical C plus plus the beginner course. My name is Zak, and in this tutorial we will be discussing concatenation now, before we actually get into Concoct Nation, which may sound like a difficult topic, which it's really not. I just kind of want to discuss this using name, space Standard one more time with you guys just to give you an idea of why it is in our code and the reason why I told you at the beginning of the Siri's not to worry about it. And that was just the reason why we're putting in our code is to make our lives easier. And I want to show you it's because when we do something as simple as cl hello world and we try to output that if we don't have this using name Space standard, all of a sudden our coat falls apart and we get an air right here in air and it says air Sea out was not declared in this scope Well, without getting into too much detail. This name space is including a function. Ah, see out the standard functions see out the output operators so we need using the name space standard just to do simple, you know, standard operations such as Output Hello World to the screen and then in the line. Now there is a way to get around this. Obviously, you could take this out and do something else to use this function, but I don't want to get into that yet because that's more of an advanced topic. I wouldn't consider that a good topic to discuss with absolute beginners and programming know that goes into using name space functions, which I consider, and advanced data structure. You know, it's similar to a class in a way which is going into object oriented design. And that's not something I want to get into in this series with you guys, because I just want to cover all the basics. And then when you get this down, maybe in a future, Siri's will go over advanced data structures and object oriented programming. But for now, we're gonna keep it simple, and we're just gonna keep using name space standard in our code. That being said, let's move on to concatenation, which is a simple and my opinion. It says it's a simple topic, even though it sounds difficult. And all concatenation is it's basically the addition of strings, and I want to show you that what I mean. So if we do string first name equals Tom and then string last name equals Jones, then we can actually out. Do you know something like string? Full name equals first name. Plus, let's add a space in there, plus last name, and we can output that we can output full name and it will output. Tom Space Jones. Let's run it. As you can see, Tom Jones appears in the Consul. So that being said, that's basically all there is to concoct nation. Now, there are a few rules. Um, you know, if you mess around with that, you're gonna find out you can't do stuff like output, Tom Place place Jones. When you output that you get an air, so you need to have a variable in between your raw strings. You need to be adding a raw string to a variable when you Dukan cat nation. Either that or two variables together. If you understand that, and if you don't, I would say cause practices concatenation topic and it will become ah, simple to understand? You know, when you can use concatenation when you can't and just messing around with it, you should, you know, get enough airs just playing around. You'll say, Oh, okay. I get what he's saying. You know, you have tohave, you know, if if I wanted to do output it Jimmy place, um, last name, I can do that. I can say Jimmy Jones, But if I want to say Jimmy Place Jones, I can't do that. That will throw in air. So that being said, that's basically all there is to strengthen Cat Nation. There are some, you know, built in library functions that you can use, but we'll gettinto built in functions later in this series. For now, I just want you to mess around with Can Cap Nation. And I wanted to show you while we have using the new space standard in our code. So thank you for watching and I'll see you in the next video 9. If Statements: Hello, everyone. Welcome to practical C Plus plus the beginner's course. My name is Zak, and in this tutorial, we will be discussing if statements now if statements are a very important part of programming and C plus plus programming. Um, because and if statement what you think of it as a way for a computer to make a decision based on certain conditions being mitt meaning if you think about like a small weather app , there might be an if statement. This says, you know, if it is raining, then show a cloud on screen. But if it is sunny, then show the sun on screen. And that's kind of what if statement is, it says if this is true, then do this. And I want to show you that I'm going to say if we're just gonna put true in here, which is a boolean variable, we're gonna go over that here in the second as well. We're going to say this code is ran. Okay, what's actually had an incline. And when we run this, I will say this code is ran because the condition inside these parentheses is true. And inside these parentheses is where you put your condition. So if we put false, okay, this code will not be ran. When we run it, you will not see this. It will just return zero and just kind of show you to kind of touch more on true and false . If you remember in the one the first tutorials over data tops, we talked about 1,000,000,000 debt data. And to do that, you talking bull because we're gonna declare a booing and data top. I don't I don't think we actually did an example of 1,000,000,000 data top, but I think we did discuss it may be and ah, I'd actually have to check and look. But boot Boolean data is a another day to top. That is either true or false. So we could say bullion, You know, um, var wine equals true and bull var too equals false. And then we could actually put the variable in here so we could say boulevard wine and which is holding the value true. And, ah, this coat will be ran if we run it. This code is ran, as you can see. So, uh, you can kind of see in this tutorial, you know, along with if statements were also kind of learning about Boolean variables, which are a very important part of C plus plus programming. It's will because all of these if statements are going, uh be focused on whether the condition inside these princes is true or false. Now, that being said, you don't have to have Boolean data in here. Um, necessarily. We could actually dio something like this. We could do it. Num wine equals five. And we can say if five is greater than three, then run this code and this is the greater the inside son. And if we do that, I will say this code is ran because actually, I hard coded five in here, but you could actually put number one is well, if number one is greater than three. And, um, I will say this code is rand the same token, though if you put if five is less than three, which it's not, then this condition is false because five is not less than three that returns false. So this code will not be ran. If we run it, you can see process return zero. This output statement was not ran, so that's pretty simple stuff. You know, you can kind of make an if statement Ryan based off of whether the condition inside here is true or false. And we're gonna go more in depth with that later in this section when we make our own at the practical add that you could use and I might even make some kind of number guessing game. I haven't decided yet, But either way, we're going to really show how we can use these if statements to make a really nice flowing code that makes decisions based on user input. So that being said, um, what if we wanted to add another part of this if statement basically saying, you know, if number one is less than three will say, um, well, actually say it will say Number one is less than three. But what if we want to say if numb one is greater than three will say Number one is greater than three. Well, to do that, we put else if number one is greater than three brackets, output number one is greater than three in line. To make it more interesting, we're going to say it numb one where I say enter a number and then put that number in them wine. And then depending on that, um, will be what code is ran. So you can say when we enter the number, it's gonna hold it in, um, wine. Okay. And if number one is less than three, this code is going to run. But it else if numb one is greater than three than this code is going to run. Watch. When we run it, what happens? Enter a number. We're gonna say 77 is greater than three. So this code down here should run. But this code right here should nine. When we hear enter, it says number one is greater than three and Onley this code ran. And so to run multiple if statements together based on one calculation, kind of you would use if and then else if and then if you wanted to basically do a default if all the above or false you add else and then brackets and then you don't add a condition to l statement. This basically says, if oil's fails, if all these return false, then do this no matter what. So just kind of thinking about it. What? What would be the default would could say, you know, if if number one is less than three, do this. If numb was greater than three, do this well. Otherwise, that would mean that number one is equal to three, right? So we could say else number point is equal to three. And to show you that we're on it and we'll enter three. I'll say Number one is equal to three because basically, we didn't even have to do a condition because its it knows that says, well, the way we did it, the way we coated it, We said, If this is false and this is false, then do this. You know, if all else fails, do this and that's what happened. But at that same token, you really don't even need this if this l statement, if you just wanted to do another else if you could say else. If numb one equals and just to This may seem confusing to you at first. But in an if statement when checking, if something is equal, you do need to equal signs. This may seem confusing at first, and it will probably take a little bit of practice, but that's just how C plus plus and even Java is coated. You know, you do need to equal signs to check a condition inside an if statement. So that's why I have to equal signs here rather than just wind, because that will actually return in air. So we need to equal signs here. So basically it's saying if number one is less than three, do this else. If number one is greater than three, do all this else if number If numb one is equal to three, then say Number one is equal to three. And that's the same thing is just saying else do this because those were really the only three possible outcomes. But you can see if you had a whole bunch of different statements, how you might just want an else statement at the end to return. A default value section is, um, you know, for instance, there's really not anything that would run this code. She would say you didn't enter a number, you know, because that's probably what would happen. Um, in fact, I think if we entered a string, it would actually return zero. It would just throw zero or a garbage value and no more in So So let's see. Let's just run it real quick if we enter three again, Um, this code will run. Number one is equal to three. But let's see if we don't enter if we enter something, the civilian try to get this code to run. Um, six years. If we Rhine just type in star or something, they will say Number one is less than three. And the reason why it's saying number one is less than three is because even though we entered Star is because Number one is a garbage value right now because we entered star and we're supposed to have an integer value inside our morning. So instead it through a garbage Valium in there, which is probably actually zero. It probably just defaulted to zero, and we can actually check at the end of everything we can actually output after all these if statements number one. So if we type in something like Zach says, number one is less than three. And the reason why, because the default value for no more and just happened to be zero. That was the value in the memory address for numb wind and That's why so So you could see how important it is that the user enters a number. Because if if he enters a string than the first branch of code is going to get, Rand, this branch right here, which may not be what you want toe happen to so it it may, you know, maybe. Ah, good idea. In a program like this, put emphasis on number. You know, um, there's obviously other ways you could handle it other than just putting emphasis on that. Um, for instance, you know, there's try and catch, um, pieces of code, but that's all advanced stuff again, so we won't be worrying about that. But when you get in, the more advanced programming you will be doing, trying catch causes and stuff like that and catching your exceptions that get thrown for whenever the user enters wrong data. So that means said, that's pretty much all there is to if statements, you know, I do think it's a good idea for you. Maybe go look up the operators that you can Do you know, for instance, um, if numb one is greater than you can also do greater than equal, which means greater than or equal to three. You can also dio less than or equal which. Basically, if number one is less than or equal to three, it will say Number one. It's less than three. If numb was greater than or equal to three, Number one is greater than three. And let's just run that and see if both codes get Rand. Because, basically, if we enter three, it will say Number one, it's less than three because Onley this code got rand but really could have ran if we just had, if instead of else, if because by putting else if it's basically adding it onto these if statements free under three again, I think all three of these election get rand. Um, let's check it real quick. I believe I d. But and I am I believe it's actually froze. But I do want you toe. I want you to play around with it right now and, um, just kind of look at all the different operators again. Um, you know, Ah, another good one to look at is not equal to exclamation point equal. That means not equal to so if it says if numb one is not equal to three run this code, And so before moving on to the next tutorial, really want your practices. If statements and really watch where you're code runs, you know when you can do stuff such as I want you to, you know, use different data tops to because you could say if, um, for instance, if you had a variable called name equals Jim, you know, string values. If you had a string in the name and if the name was GM, you could basically run this code. If name equals, Jim will say Welcome, Jim or something like that, So just mess around with it. Practice with ease if statements. And in the next tutorial, we're gonna look at an alternative to if statements called switch statements and you will kind of be ableto decide on your own, which ones you like using more in your code or when's the right situation to use? Which one is, and I think you'll find it pretty interesting. So stay tuned 10. Switch Statements: Hello, everyone. Welcome to practical C Plus plus programming the begin. Of course. My name is Zak. And in this tutorial, we will be discussing switch statement. Now, As I said in the previous tutorial, a switch statement is basically just an alternative to an if statement, but they are used in different scenarios. Now, I'm gonna go ahead and kind of give you an example of what a switch statement looks like and then discussed you how it works. So gonna go ahead and type out everything right here is where the switch statement starts. Okay, Groups, You put everything in brackets, go ahead and give you some room, and then you put your cases in. So here is our sweet statement. The basic functionality of a switch statement. Okay. And I attacked it out because I just kind of want you fall along. It's gonna be easier for me to explain it to you like this. So here we have a variable called Raid and our great isn't be okay. And then below that, we have our sweet statement defined in these brackets right here. Everything in these brackets. Okay, So, basically, to define a switch statement, you write the word switch and then in parentheses. Next to that, you put the variable that you are analyzing. And this Kate it In this case, it's grade. So we put grade here, and then in your brackets, you put your cases, so you put case and then what you're comparing the grade to. In this case, we're comparing it to different letter grades. So the 1st 1 is case A. And here you enter more brackets and you put the code that you want for case A. So you made a 90 or above. And then in Case V, you do the same thing. You can put your code here, you made a 80. Or, Abed, you can repeat that for each of these. And we're gonna go ahead and do it here so that you get full visual ization of how the switch statement works. In case F, you failed. So basically what's happening here is this code runs. We have a grade of a B, and then we look in the switch statement. We tell the switch statement to analyze grade, which is be so right here is grade. The variable that we're analyzing, we say, isn't in a well, no, it's not. Is it to be well, yes, it ISS So we're going to run this code. Is it a C? Well, no, it's not. Isn't NF well? No, it's not. So this is the only code that you get ran, but I want to show you something real quick so that you can You can see what happens when before I fix it. Let's go ahead and run this program and you can see it says you made an 80 or above you made a 70 or above You failed. Well, that's interesting because we made a B. It said everything except a But once he got to be, it basically did all the Cobell obi. And that's because, and a switch statement you need to add a break. And to do that after all your code, you say break and you do that at the end of each case to tell it to leave the sweet statement because switch statements have what I like to call a waterfall effect, meaning If you don't put your break and right here on this code to break from this switch statement, then once this is crew is gonna waterfall down into the rest of the code, the rest of the switch state and code. So if we took out this break statement right here, it should Ryan the B code and then run the C code before it breaks. Let's check it out. As you could see, it said you made an 80 year above you made a 70 year above because it didn't break from the sweet statement until it got right here. So what we need to change is, of course, if we just add a break here, you'll see that it says you made it a year. But because our greatest be and just to kind of show you how we can further this let's do grade and then we'll say something like Inter a grade, enter a letter grade, okay? And then let's you see in tow, hold our grade and then let's watch how this sweet state is He's injury letter. Great. We're gonna enter F. It says you failed because basically, it went through the sweet statement that put the grade we entered in here in the sweet statement, analyzed it. Look for the case is that in a no is it be? No. Is it a c? No. Is it in f? Yes, you failed. And that's how switch statement works. Okay, so that's right. One more time we're gonna enter in what's interim and eight and says he made a 90 year above. So that's the basic functionality of a switch statement, and you can see how it's very similar to an if statement by checking which condition is met . And like an else statement in an if statement, a switch statement also has something similar to else, which is called default. So if we wanted to take out this f, we can just say default. You made an Don't worry, you failed. Which is the same thing is saying is if none of these were true and obviously he failed, let's let's go to the default sweet statement, which is? He failed. If we run that and we enter in and f well, that's even entering and D. It'll say you failed because if we enter into D, obviously A, B and C aren't aren't a d. So it's going to go the default. Just say you failed, but you know, obviously find Rizzi. That same code is gonna run because it's either a, B or C. So if you want in tow to restrict the user to Onley entering the correct letter grades, what you would probably want to do is say something along lines of case. If and then output, you failed in line and then on the deep ball, you could say something like You entered an in valid letter grade. And now when you run the code, if it's not ABC, or if if you enter something like our will say you entered invalid letter grade because it's going to the default. So that's the basic functionality of switch statements, and I will see you in the next tutorial. 11. Practical Program #1: Hello. Welcome to Practical C Plus plus programming mining, Bizet. In this tutorial, we're going to be taking a look at her first practical program that we're gonna make together. And it's just gonna be a simple calculator at and to do it. The main focus of this is I want you kind of understand how we're gonna structure this program and use the concepts that we've already gone over to make it work. Like we wanted to. That being said, let's go ahead and begin and that the way I want to structure this is basically, we're gonna make a calculator that lets the user decide at the very beginning. If he wants to do addition, subtraction, multiplication or division. And to do that, we're gonna use a switch statement. Okay, so let's go ahead and structure. It s so we're gonna right switch. And then there we go. Sorry about that, guys. I am. The rest of my brackets got deleted. There we go. That's right. It just like that. Make sure you get your return statement, okay? And then in this switch statement is gonna be the variable that we're checking and the while I do it is, I basically wanna have the program opened up and have numbers. 134 ill say one addition to subtraction. Three multiplication and four division. And so to do that, we're gonna hold A variables were going to say it and we'll call it choice. Okay? And we're just gonna leave it like that. We're gonna say, see out, Enter a choice. Actually, the way we're going to do this, we want to let them know beforehand on what their options are. So we'll say Wine addition. Okay. In line to sub track in line three, Malta application in line and four division in line. So this is what they're going to see. They're going to see basically this on screen, and they're gonna have to make a choice on what they want to use. And then what we'll do is we'll say, at the very end, let's give a little bit more space, and we'll say, enter a choice, and then we're gonna hold that with a C and statement and choice or variable choice. So kinda if you need to push, pause and kind of breathe all this in exactly what we're doing. This is all stuff we've covered in the previous tutorials, and it should be fairly straightforward to you at this point. So at this point, we're holding the integer of the choice that the user selected into choice. So what we do is and switch, we need to put the variable that we're analyzing, which is our choice variable and then make cases. So obviously we'll have case wine case two case three case for let's go ahead and add a default as so okay. And obviously the deep all we can go ahead and add something like exiting you entered and in valid number eso because basically, we're going to say if they don't enter wine and they don't enter to or they don't under three or they don't enter four billion or something else and we're gonna say, exiting you entered something invalid and then it's just gonna go straight to this code return zero in the program will end. So that's how we're gonna handle that Now, in these, let's go ahead. And just so we don't forget, we're gonna add brackets to all of these as so that way, These are format and nice and easy, so that we can see. You know, Case three is gonna be right here. Case for is gonna be right here, and we're gonna go ahead and add or break statements so that we don't forget, because that's gonna be very important. These break statements were very important for this code, the way we're structuring it because you don't want multiplication and division to be run on the same at the same time. So let's go ahead and add or break statements, which is a good practice to do with sweet statements. They don't forget. I would recommend always adding your break statements first, if they're necessary. So there we go. So, as you can see, if you need push pause and kind of look at this, Matri had everything right. Go induce of now because this is how our program, our calculator, is gonna be structured. Is that so? With a switch statement? Okay, so that me and said Now that we have or choice entered, basically, everything is going to be the same at this point. So we'll say right here will say, Enter number one and just a the top. Let's go ahead and add our new variables. So we have choice here and if in you may see people to a different way. But the convention that I learned in school was always declare your variables at the top of your main function or at the top of any function that you're in, for that matter. So that's what we're gonna do. You just taken getting a good habit of doing it. Let's give us a little bit space. We have any choice, our sweet statement, and then we're gonna have We're gonna use doubles in case they decide they want to use, you know, floating point values for their calculations. So we're going to say double number wine. And then actually, before putting our seven corn here, I'm gonna Mills were going to say number two, which is a new way. This is another way you can declare your variables, and this basically says double number one and then double number two. You can declare him like this is the same. Both of these air doubled, and we're not initializing them to anything. We're just making two variables of the data Titan double, so you can try that out and again. It's a convention you could do. You could just write double number two down here if you wanted, but it's all a matter of preference. So we're gonna leave it like that for now. And then we're actually gonna add one more thing. We're gonna We'll just, uh, believe that just like that. Actually, we got, say, on each of these, we're gonna have him enter the number one in the number two. So the codes gonna be pretty repetitive, actually, on each one. So I'll say, see out into number one. Okay. And then CNN number one Okay. And then we're going to say we're gonna give a little bit of space, and we're gonna say Enter number to We're gonna get the input for a number two. Okay, Then we're gonna output. We're gonna give us plenty of rain. Okay? We're gonna tell him the result. We're gonna do it like this, cause so you can see the the numbers don't run off the board. We're going to say result equals Okay. And then we're gonna say since case one is addition, we're going to say number one plus number to and then break, and this code is gonna be pretty repetitive. So if you want You can just copy this because I could said it's gonna be the same for each one. Pretty much have pasted in here. Okay, True. Fix your formatting in the copy and paste mint stuff. Remember, Case to is subtraction. So the only one you're really gonna have to change is this change that to anonymous Case three was multiplication. So we'll just have to change the sedition to a multiply. A sign in case for was division will change that to a divisions on. So there you go. So now our program should run just like we want. We got our switch statements and everything. How it needs to be. Gwen. Save it will say build and run and let's see what happens. So there we go. As you can see on screen, we have our choices, Addition, subtraction, multiplication and division. Let's go ahead, Inter subtraction. I will say inter number one. So let's do five. Inter number 23 Well, say result equals to process ends. Have a subtraction. Let's go ahead and do ah, Division four else they enter number one. I kind of want to show you something with division. Um, because I don't know if we went over this in arithmetic. But let's say I dio that's how Do non Okay And then we do for number two, we do four, so they'll be non about about four. Obviously, there's a remainder there, but just straight division, it's not gonna give you the remainder. That's just gonna give you two, because it goes into it two times. Now you can see that the result was 2.25 And this is an interesting topic. If you if you practiced your arithmetic, the reason why we're actually getting a decimal. The actual answer is because we're doing double on double division. So we haven't since both of these or doubles the results gonna be in double. But let's change these two integers for a second. We're going to do that same That same problem there were going to four. We're going to non divided by four, and we should get to, As you can see, we can get to you even though the real answer is 2.25 And that's because reason whole number division and not allowing for a double, uh, result value. And that's really what we need to do if we you know, if you want into your just make it simple, you just change this to double And the other alternative would be If you want into, you could just leave these as integers and then hard code, a double result value. And basically, you could go down here and say result equals, um, you know, here you could say result equals number one plus number two and then say result equals result, and that will still give you in double value because you declare results in dough. But this was our first practical program. I just wanted to show you how we're gonna use everything that we learned throughout this course to actually actually applied to practical situations. This is the 1st 1 you know. We used our switch statement going. Thing we really didn't use to mention here was an if statement. But if you take the same token, if you want tried on herself, you can switch out the switch statement for an if statement. So to do you know, if choice equals Boyne, do this else if choice equals to do this and so on and so on. So I challenge you to do that are trying to try to this program with sweet statements and not telling you trying to it with, um if statements. Thank you for watching. And in the next tutorial, we're going to go on to more intermediate programming topics, So thank you for watching. 12. While and Do-While Loops: Hello. Welcome to Practical C Plus plus programming the beginner course. My name is Zak. And in this tutorial and this section in general, we're gonna be discussing a little bit more intermediate topics. And ah, starting off, we're gonna discuss looping such as while and do I leaps. And this should be a pretty short tutorial because we're not gonna go too much in depth about. We're just gonna kind of discuss how to use them. And once we get further into this section, you'll see the practical use of them and how often you will actually be using them real life situations. So let's go ahead and show how to define the loop. We're going to start with a Y, a leap such as this while you taught the word wild. And then you put your parentheses for your condition, and then your brackets and basically anything in your brackets right here will be run. As long as this condition is true. On this condition is true. This condition is checked. Better to say this condition is checked at the beginning of the loop, the code is ran and then it's checked again. And if it's still true, the code continues to write. So the best way I can say this is, um let's go ahead and do it like this. We're gonna say int um, Rhine equals 10. Okay? And then we're gonna basically say, See out, Ryen, see out, run, end line. Okay. And then we'll say brine equals run minus wine. Okay? And in this loop for the condemned for the condition, we're going to say, while run is greater than or equal to zero. Remember, we discussed this operator. That means greater than or equal to zero. Okay, so moving nine. Basically, this is going to say, while this is true, do this. And if you look at the end of our code, basically, we're saying we're setting run equal to run minus one. So the first time the code runs, um, run equals 2 10 and then the next time it equals two. Not until it gets to zero, and then it should quit running. So let's run it quit. And as you can see it that real quick, but it printed off because we're out putting get 10 9 all the way down to zero. And that's basically what we want. You to do? Um, one more. One thing I won't discuss that maybe we haven't discussed earlier in the arithmetic because there really is a lot of rithmetic things you can do and C plus. Plus, they're very interesting, and one of them I want to show you now over our while we can use it. Is this when we say run equals run minus wine Another way in C plus plus that weaken do that is, say, for it's actually easier less. Code writes, a run equals Monets wine. And what that does is that basically means run equals run minus one. And it would be the same thing if he said, run equals plus one. So say, Let's just run it real quick and you'll see that we get the same result. You're just gonna have to visualize. Okay, so it's wrong right there. I was wrong about that. So it may be it's minus equals. I believe it's minus equals wind. Yes, that's right. So I had it backwards. Sorry about that. So So this right here, this minus equals or if you did plus equals, is the same thing as saying Rhine equals run minus wine. So if we do that, obviously we're going to get the same thing is run equals run minus one. Right now, the one thing about that's dangerous about loops is that you could get caught in an infinite leap. Okay, so that means said, if we did, you know, Rhine plus equals one that sent and say run equals run plus point. Obviously, the variable will never get to zero, and this thing will be caught in an infinite loop. We're gonna go ahead and hit building, Ryan. So you can see what happens when this, uh when you get in this situation. And as you can see on screen, the number is just adding up very quickly. You can see how fast processor is clicking through these numbers going through this leap. I mean, it's almost instantaneous Will be 100,000. This Coby ran 100,000 right about now, you can see we've already ran this code over 100,000 times. And if you get caught in this, one thing that I would recommend doing is goes pushing control, see on windows, and that shuts it down. So if you get caught in an infinite loop on windows hit control C. I just come one to show you what that was. And, um so yeah, it infinitely hit control C and get out of it. And that's one thing you need to watch for. You know, when you're doing this is to make sure you get your code writing that you think about in your head first before you run it so that you don't get caught mothers infinite loops and have your computer accidentally crash. So there's a difference between minus equals and plus equals. You see how much different the code is, rather than getting in an infinite loop. It it quits because this statement is no longer true. Once run is less than one. So once it gets to negative oin, it doesn't run anymore and it goes ahead. It's return zero. So that that is a wild loop. Okay, so now I'm gonna introduce a do while loop and a dual leap basically says, Do this anything in here and then it checks the condition at the end, while Ryan is greater than or equal 20 Okay. And then you put a semi colon, so it's a little bit different syntax. You say do and then your brackets, and then while your condition and then it's semi colon. So let's see what the difference is between this having your having your condition checked at the end of the code rather than the beginning. But the difference is this. If we set and run equal to negative five, obviously it's not greater than or equal to zero. But the difference is, is this. This code will always Rhine at least annoyance, So I'll show you what I mean. Even though run is less than zero. When we run this, the code will still get Rand once and shows it's negative. Five. Okay, so that's the difference between a wall and and do well. But you can still have the same. You know, you say, Well, when would I use that? Well, when we get into more practical examples, you'll see these Duvall. And while loops are used interchangeably, depending on the situation, you know, if you want your code to run at least once, no matter what, then, obviously, and do all this more appropriate than a while loop. But just cachet that we can still get the same result out of this code is wildly. We're gonna go ahead and set, run equal to 10 leave our condition is the same and say run Mantis equals one. We should get the same result as before 10 all the way down through zero. So that's basically an introduction on loops and, uh, particularly just with a focus on while and do while loops in the coming tutorials, We're gonna go into four loops and more fun stuff like that, so stay tuned. 13. For Loops: Hello. Welcome to Practical C Plus plus programming the begin. Of course. My name is Zak. And in this tutorial, we will be discussing four leaps. Now, in the last tutorial, we discussed wild leaps, and I got to say four loops are quite different, and you'll see why here in a minute. So the way of four loops works. You're gonna go ahead and set it up the same. You're going to say four your condition and then the brackets, just as you would a while loop or an if statement. You just proceeded, you know, before the condition is where you write four. So the confusing part too many people is the condition inside the four leave and how it works, and I'm gonna go ahead and explain it to you all. But first time I set up a variable, call it value, and we'll say, um, equal. Actually, the way we're gonna do it is yeah, Well, say value equals zero. Okay, we're just set value equal to zero. And then here in the four Lee, we're going to declare an integer called index. We're gonna set it equal to zero, okay? And then put a semi Colon. Now just stick with me for a second, because it I know right now you're thinking What? That's that right there. You're declaring something in a condition. Well, this is not the whole condition. This is only 1/3 of the condition. So after you declare your variable int index equals 20 we're going to say index less Van 10 and then we'll say Index plus place. Now, I want you sit here and breathe this in for a second, because I know it looks complicated. Especially if this is your first time ever looking at afford a leap. So basically what we're doing in this four Lee, where declaring indexes variable in setting, get equal to zero. Okay. And then were saying this right here is basically our condition is what I would call the condition Assad from these other two. This middle part says, do this wild loop as long as index is less than 10. And then this third part is what I like to call the increment. The incremental part of the four loop. This is how much one increments each time. Baluch Rhines the variable that you're testing Index and I mentioned earlier in the last tutorial. I believe that minus equals was the same thing is saying index equals index minus one. Well in C plus place index plus plus is the same thing. That same index equals index plus wine. So easier way to write that is to just say index plus plus. And I know Ah, we did you know something like index minus equals one. Well, another way to do that, actually in the last tutorial could have just been index minus minus is well, so that's the same thing as saying index minus equals one. And that's also the same thing. And saying, index, um, monness index equals index minus one, Just as this is the same thing is saying index, this is the Sundays and index equals index plus one. So just keep that mind index plus plus were incriminating index by wine each time. The code inside this loop runs and what I want to do is I want to say, see out value en del, and what we'll do is we'll actually add, um will add five the value each time. So if we run this, you'll see we get 05 10 all the way up to 45 because this code is ran all the way until index equals 10. And each time this four loop is ran indexes getting incriminated by wine on one index equals 10. That means index is no longer less than 10. And the four loop jumps down here to return zero and you get process returned. Zero. So just to kind of take kind of show you a little bit more about it, let me let me actually take out value. We're gonna output index is what we'll do instead. And you can actually see what happens to index throughout the four loop. We're gonna hit Rhine. Let me, um let me get rid of this real quick. That was still open. We're gonna hit Ryen, and you can see what happens to indexes. It goes through the leap. Um, it goes from zero all the way up to nine and then loop ends. So I want you to practice with this four loops. See how you conduce different counting exercises and kind of cycle through numbers with this four loop and, you know, even even tried changing this operator Teoh index may be greater than 10 and see how that changes it. Um, you know, because obviously, if we ran this right now, it wouldn't even run. It would just return, because index start zero. So indexes never actually greater than 10. So this code never runs. And also, I want you to try, you know? You know, obviously we declared index right here. But what if we just said index equals 20 and we changed this value? We said index right here equals zero where we just said it index. Then we don't have to put right here. We can just right, index, and we can actually declare it like that. So there's different ways you can, um, kind of, I guess, declare this four loop. And I know right now, just counting through these loops like we have in and adding numbers doesn't seem very practical. But I promise you, by the end of this section, you will see very useful and practical examples of how we will use these four loops. So stay tuned for the next tutorial. Thank you. 14. Data Structures - Arrays: Hello. Welcome to Practical C Plus plus programming. My name is Zak. And in this tutorial, we will be discussing a raise, which is basically my introduction to data structures because I see an array as the most simplest, the most simple data structure that we can kind of delve into without getting too advanced . And I really went to introduce these arrays because you can use four loops and while leaves is a way of populating these rays and we'll get into that probably at the end of this tutorial. But to start off with what is an array? Well, an array is basically the best way I can explain. It is a list. So the way I was taught was think about when you go to the grocery store. Let's do this together. So we're going to declare an array, We're going to call it String. We're gonna make an array of strings, Okay, strength, and we're gonna call it grocery list. Okay, this is our grocery list. And this. I want you think of an array because it will give you a really good visualization. So we're going to the grocery store, and we need to buy several things we need by eggs when you buy milk, we need buy bread when you put all these things on the list. Well, to do that, we need to know how many items are gonna be on our list, First of all, with an array. And to do that, you put two brackets like this, not curly brackets, but straight brackets. And inside here we put a constant value. Variables are not allowed on the inside of the brackets during the declaration of an array , and that's very important to remember. So you have to know how many items you are going to populate your array with when you start . That means said, let's go ahead and assume we're going toe have only three items on our list. Okay, so we're gonna put the value three here. Now, the next part is to put these items in our list so he right equals and then curly brackets . And inside these curly brackets is where we write the items on our list. Now, obviously, we declared this grocery list is a string data type, which means we have to put string elements inside this array. So the first element is going to be Eggs were going to say we want eggs, Okay. And then you separate each element with a comma. We'll say we need milk. And then we'll say we need bread and then end three declaration with semi colon. So this right here is your first declaration of an array in C plus plus. And it's fairly simple. You just have to remember that you need to put the constant number of items right here in the brackets, and then you declare each item each element in the array, so to speak, and the curly brackets over here. Now, you may be thinking how when would I use an array? Well, you're going to use it all the time. We were gonna go into that later, but before we do that, I want to discuss this value right here. This three. Now that we wrote a three right here and we can't put variable. So, for instance, if we wrote into index equals three were not allowed to put index right here during our declaration. And I believe code blocks co blocks sometimes lets you get away with it, but actually it doesn't see, I just try to run it and I got on air. And that's why because we put a variable here, you're not allowed to put a variable there. However, I want to go ahead. And while we're on this topic discussed constants with you and a constant is different from a variable in that it never changes. Meaning what? All you have to do is add the constant keyword, which is CEO Seo in S T c o N s T. Const it index three. So now if we run, this index becomes a constant value in the program. The program runs now. Keep in mind when you add CONST. Right here. You are not allowed to change index later in the value. So if I try to say index equals to two all of a sudden or index plus plus, I will all of a sudden get an air because you are not allowed to change values that have the constant keyword in it because it's constant. It's not supposed to change throughout your program, so I just want you to keep that in mind. The other thing with Constance I want you to keep in mind is that it's often a convention to make constants in all capital letters and C plus plus so that when you look through the program, you automatically know what's a constant and what isn't. And so this is how you would probably see it most C plus plus programs. And though Index probably isn't a really good name, you would probably want to say something like Size Size is probably a a better word for the array constant. And that's usually how you'll see it in C plus plus programs when you're talking about a raise. Now I do want to go into we discuss four leaps last time in our last tutorial, and I want to go ahead and dive into how we're gonna use four loops and a raise together. And that's why I made a raise as our next tutorial after four leaps. So that would be fresh on your mind and you can see exactly how we're gonna use it. So let me go ahead and show you that Now we're gonna make a four leap, okay? And in this four loop were going to say integer index equals 20 and then we're going to say index less van size index plus plus. Now think about this for a minute. We're declaring a new variable called Index, and we're setting it equal to zero. Then we're saying, Index, this is our condition. We want to do this for loot. While index is less than size and size, we set to three, which is also the size of our stringer A. And there were incriminating index by one each time we run through this for lead. So this four loop If we ran it, we'll just see out index real quick so you can see it. It should only run three times. And if we run it, that's exactly what you'll see. 0123 times. And remember, index starts zero. Now when you look at a raise, this is a very important thing to know, because if you don't understand this concept, a race will get very confusing, and that is to access an array. So let's go ahead and access grocery list. We're going to say output grocery list, and then you put brackets okay and L and inside these brackets you put the number that you want to output. So that means said, let's let's go ahead and say, Um, we want to output eggs. No, let's say we want to output milk. Okay, So if we want to output milk, you would think you would enter to hear right. Well, that's wrong, because the thing with computers is in a race, especially, is a start counting it? Zero. So if you wanted to output the word milk, you would have to say grocery list and then put one in the brackets. Because this is index zero. This is index wine, and this is index, too, Which is why, oftentimes of four loops, you're going to see him start at zero. Because in a four Lee, oftentimes he used a raise or even vectors, and they all start counting it. Zero. Which is why you will always see most of the time in your program a career. These four loops start with a variable. There's initialized it. Zero. So that means said, we can actually put Index in this box to print out zero. The next time it'll count through will be one the next time it will be, too. So it printout eggs, milk and then bread. Now going back to a topic we discussed at the beginning, we said that you could only have constants in these brackets, and right here we have a variable. Well, the constant rule only applies when you're initializing the list. When you are actually accessing the array, you can use variables as we are right here. So let's go ahead and run this program and we'll see. We get eggs, milk and bread. It prints out the whole list for us. So, as you can see, this is a very practical example of using a for loop to iterated through a string, um, array, which we declared is a grocery list. And when we get further into this section, we're really gonna take this to the next level, and I think you're really going to enjoy it. So stay tuned and thank you for watching. 15. File Output: Hello. Welcome to Practical C Plus plus programming the beginner course. My name is Zak. And in this tutorial, we will be discussing file output. Now, In earlier sections, we talked about just basic console output, and I want to stress that you to not get too, um, concerned about file output because it it's actually a lot more simple than it's going to seem at first. It's gonna be a lot of new stuff, but if you just look at it and practice it, you will see how much more simple it actually is. Then it's gonna first appear that being said, the first thing we have to do when dealing with file output is include a new library. So we've been using this pound include Io String, which stands for input output stream. And we still need this library for for a programmer work. But we need to add a new one. And to do that, we're going to say pound include, and the new library that we're using is called F Stream, which stands for file stream. They have input output stream, and now we have filed stream. Okay, so the next thing we're going to do is declare an output stream, um, file, so to speak and output sharing file that we're going to use. And to do that, we say, oh, F Stream, which stands for output File stream, and then you give the output file, stream a name, and we're just gonna call it output file. Okay, now, output file. What you want to do is add parentheses and put a semi colon. And in these parentheses, I want you to declare the file name of the output file that you want to use now. That being said, if there's already an output file that is, that has been made, that is, in the current directory. Then, of course, you just want to enter that file name. Now, if it's in a different directory, you're gonna have to specify the full path. And to do that, you would say, you know, see, for the c drive. Um, Colt, you know, colon backslash, backslash users, backslash, backslash, and you do have to have double backslash when using the strings. And ah, without going to mention debt, you know, without cause I would really need to put that in a new tutorial. And ah, I will actually make a tutorial about that. But the first backslash window, almost strings, is considered an escape character. So just know that whenever you're specifying these files and you use a backslash, you need to put two of them in order for the 1st 1 to be read. So that's how I would do that. But for me, I'm just going to declare a new file, and it's gonna be in the current directory. I'm just going to call it names dot txt just like that. And if you run this, everything should run final, just return zero. And you know that you don't get any heirs now named Start txt is gonna be the name of our output file that just got created. So if we actually go to open right here, it should have created the name stuck txt file right here, as you can see for us since we just ran the program. So now that the file is created and everything is fine, we can actually start riding to that file now, before we do that, it's always good practice to have a branching statement in case something goes wrong with creating that file or finding it. And what I like to do is say, if no, I output file, which means output file, if not output file. It basically means if if the output file returns false meaning that it couldn't be created , then run this code. So that means if the help a foul name start txt could not be created nor found, then do this and we'll just output. The file could not be found, and then we'll say, return negative five and this can be any value, actually return negative seven. I could say Return on. I should put a negative value aknegative 10 or negative five. And that way, when we run, the program will run it right now if it says process returned. Negative. Five. I know that the file was not found, and you just use a a random number like that that you can easily associate with an air, and that would definitely been air. But since process returned zero, we know that names dot txt was created, so let's move on and let's actually write to this file. And to do that, let's create a string name equals Zach, and that's gonna be a fairly easy ah example. And whenever we make our practical program at the end of the section will see a more ah, in debt way of looking at file output. But for now, I'm just going to show you an easy that's in the simplest way I can, how it's performed. So we're gonna make string name equals AC. And now we're just gonna write that name to have fallen. To do that, we use our output stream name and the handle on that is called Output File. And then to write to it, you use the output operators as so let's say, unless saying, just like if we were doing see out the output to the screen, we used these less and less. Then instead, we're going to do output file, which is our output stream appear and we're using output file. That's the handle name you should say so output file less and less than name and then return zero. And if we run that everything should run, find with no heirs. And if we open, let's just open named start Txt year old Quit. We're gonna open it right here and you can see Zack was written to this file So that is a basic introduction on file output. And in the next tutorial, we're gonna discuss file input, which is actually a little bit more complicated. So stay tuned and thank you for watching. 16. File Input: Hello, everyone. Welcome to practical C Plus plus programming. My name is Zak, and in this tutorial, we will be discussing file input. Now, as we file output, the first thing we need to do is include the right library. That's gonna be the same library viol stream F stream, and then the We also need to declare a file handle that we're going to be in putting in using the if stream declaration. So in output stream, we use OEF stream and input stream. We're gonna use I f stream for input file string. Now the difference is in input. We need to already have a files. Specify that we're reading from. You know, you don't want the file to be empty. You wanna have a file that ah has data in its That's what we're gonna do. We're gonna use named start. Txt is from the last tutorial, and I'll go ahead and open it real quick so we can add some data we're gonna use names such as, Ah, will use Zack, Um, Troy, Sam, Jim, Mark and Kristen and Margaret Taylor, Um, Jake and, um, Sherry and Francis as the names for our We're just gonna basically make a name list. So these are all names. And let's say we're wanting to read these names in from this file and, um, store them in a variable. So to do that, we need to know the name of the file and declare a file. So we're gonna say will say input file. And we need to declare the name of the file that we're reading from, which was named dot txt. So we're reading from names dot txt. And as with output file, we just need to go ahead and say if night input file C L file not found in Taiwan and let's return a value like negative six is that we know it wouldn't be found. And let's go ahead and run it and we got process return zero. So named start txt was found, and it should be because it has been created. All these names in it. And remember, this is just a cautionary thing. So you your file for some reason comes up missing. It'll return negative six, and you'll know that it that it's gone. This is good again. Just a practical way to, ah code your program to look for heirs and problems with the with the code. So moving on, um, let's go ahead and create something to store these names in. And if you if you want to think about you know, the things that we've gone over, probably the perfect I think that we could use as a data structure sections an array, and we can just make one variable one array and then store all the names in that array. And so to do that, what we'll do is we'll say, um, you know one thing. One thing about an array is that we have. You could have an unknown number of, um, unknown number of names here, but and obviously, if that was the case, you would probably want to use a a different dead data structure. But since this is the beginning of beginner's course, we're gonna go ahead and use an array, or we're gonna assume that we know how many names are in the file. If I If I teach in advance course, but but you know, kind of depending on how how well this one does, if I teach in advance course, we're gonna definitely go into more advanced data structures and a better way to store this data whenever you know the amount of names is not known. But, like I said, for now, we're gonna go ahead and assume that we know how many names you're gonna be on this list. So it's countem ups. 123456789 10 11. So there's 11 names, So let's just let's go ahead and declare a constant value. Constant in size equals 11 and we use that for the size of our list. OK, and then let's go ahead and make an array. Like I said, I like to do. It's kind of a convention to declare your raised the beginning of the functions. That's what going to do. We're gonna declare the array, and it's it's gonna hold string values because these are all string values Alfa numeric, you know, uh, multiple character values. So, um, we're gonna use a string and will say, um, names list. We're gonna hold size for the value, and we're just going to declare just like that, as um, actually, I think the better way to do that would say equal and then brackets and then just do that just like that. And if we run that that should not get. Give us an air and it doesn't. And the reason why is because co blocks and most ID's will see this as instead of having to basically do empty strings 11 times to declare this array. If you just put one empty string in there, co box goes ahead and assumes to set all the default values to this an empty string, which is what we want. We want the strings to start out empty so that we can put new ones in their place later. So that's basically were initializing this array to a bunch of empty string values. That means said, Let's go ahead and get to where we can read in these thes file names. And to do that, the best way to do it is with a pre read and a post read within a wild leap, and you can play with this you want and kind of figure out the best way that you see fit. But when you do it with this wildly, you're going to realize that the pre read on Post Street is actually the best way to go about it because oftentimes, if you don't use a pre read and if you don't do a post read, you're gonna figure out that either you're going to read the last name twice or you won't read the first name at all. And this. That's why I like to use this strategy to read from a text files and I'll show you exactly what I mean in a second. So so beginning with the pre read This is gonna be the pre read and we'll go ahead and comments that I will say pre read. And if you didn't know, I know we haven't discussed this yet in any of the other tutorials to comment code. You just used double backslash that will comment code. So if I if I write double backslash, I can write whatever I want, and it won't affect the code at this point, so to kind of keep track of what you're doing, it might be a good idea to actually comment your code, especially when you get toe pretty, reads and Post reads, because it will make it easier to read when you go back and look at it, starting with the pre read you're gonna use the file handle, which is input file. And then they used the input stream operator, which is greater than greater than if you remember. I'm seeing operator. And then you're gonna store the the, um the the the name The string from named start. Txt. Sorry, I got my I got my words twisted there for a second. You're going to store the stream taken from this file into a variable declared here. Now, it's not advised to put this straight into her straight into an array. So what we're gonna do is we're gonna is gonna say strained. Um, tip name. And we're just gonna leave it like that. We're gonna put it into a variable called temp name. So the first time it reads is gonna read Zack, and it's going to store it here into temp name. Okay, Now, let's make a wild leap, and this will all make sense after we're done coding it and you'll see why. So then we make a while leave and we say, while not input file dot e o f parentheses and this dot e o f is a function and we'll go over more with functions and next tutorial, but it stains for end of file. So basically this condition says wow, input files, not at the end of its file. So basically went, reads through the cursor starts here. And as we read through it, the cursor is gonna move like this all the way down through this file as this wildly continues until the cursor gets to hear of the end of Francis. And that's considered an Indo file because there's no more text in this vile and ah, as long as it's not a day into the foul. This while loop is gonna keep looping. That's why I like to use for my loop. And while it's not at the end of file, go ahead and it interview times comment post read. We're going to say do the same thing is Thea pre greed just temp name and this right here. This pre read this post read in this while loop is your basic set up for file input, and I know right now you're saying that is really complicated. It doesn't make sense, but this is the best way to receive input from a file and you'll see why I want you to play with it and see if you can figure out a better way to do it. But I think I think once you play with it for a while, you're going to realize that this is definitely the cleanest way to receive foul from ah received text from an input file. So let's go ahead and continue on. And you always want the post re to be the last thing in your wild leap in your pre read to be the first thing. They're the last thing before your wild leap. So you never want anything in between your wildly like right here and you're pretty read. And he never won anything in between your post read and the end of your wild leap right here. And that's just a golden rule for foul input. So but anything anything that you want to do, um, you know, data processing wise congee Oh, in between here and that's exactly what we're gonna do. So we're going to say we're basically going to say input or we're going to say, How about this? The name was names list, so we'll say names list. Let's go ahead and declare an integer value so we'll say int index equals zero. We're going to say names, lists, indexes got started. The first Valiant Names list equals temp name. And then we'll say Index plus plus on. What that's going to do is it's gonna go through. Each name in this file is going to start with Zach, and it's going to start Index zero. Go to the first index and names list is gonna store Zach because Zach is me and held in temp name. There's gonna add one to index. It's going to the Post read. It's going to go back up to the top of this wild leap and is gonna put the next name on the list Troy into our array. And if you don't believe me, we're gonna hit run, you'll get no airs and nothing happened. So as of right now, there's no output. But I promise you, it just populated the whole array. Our whole names list array with the with the names in this violin to prove it to you. We're going to use a four loop on the outside of this wild leaps, so we're going to say four. It was called I equals 20 I less than size I plus place. And then we're just going to go through this Ah, this loop and prove to you that names list is populated with the names and are named start txt file. So we'll say names list I and a lot. And if we run this now it's gonna output are array. And right now it just says Francis. So let's take a look at what went wrong there. So something's gone wrong with our names dot txt. So we have. We have Francis here. Maybe. I believe it has something to do with the way we declared this array with this empty string . So let's see if we take this out. If that will fix it real quick, Let's hit run and it's still, says Francis. So we're having an issue with our with our, um, array declaration because I know for a fact we're getting the input file and we're storing it in Tempt name and them were using the index Teoh there. There's your problem right there. So So obviously, if indexes at the beginning of the while loop then and we're declaring it to zero that each time this while loop runs is gonna set index back to zero. So what we need to do is we need toe, take this index equals zero out and put it on the outside of our wildly. That way, it's only declared 20 once. Now, when we run our program, we will get all the names in our list as a minor is a minor mistake. Obviously it ah, completely changed output of the program. And so you really gotta look out for that stuff. And, um, if you didn't really get the mistake like I said, we had index equals zero at the top of our wild leaps. So every time this loop brand, it was setting index back to zero, which is why it has to be on the outside of our wildly. But I think you should definitely go through this program several times because when I first started C plus place, I found foul input is a pretty complicated topic. So go through this program in this tutorial several times, practice the pre read in the post read, and I promise you, when you get it down, it will make a whole lot of sense. And ah, it'll just be another thing to you will be very simple. So thank you for watching and stay teamed 17. Advanced Input and Output Manipulation: Hello. Welcome to Practical C Plus plus programming the beginner course planning Izet. In this tutorial, we will be discussing advanced input and output manipulation. And to do that, I've already got the code that we used from the last tutorial with foul input. If you remember, were just grabbing some names from this names dot txt file. And we're storing them in a variable when we read it in and are pre read. And then as long as we haven't reached the end of file, we are taking this temp variable and copying it to our array with the index of zero. And then we add one to it each time as we go through the output. It was just this names list that we have, but what I want discuss is these tips and tricks for advanced file input, output manipulation and these techniques are going to help you whenever you get in funny situations. The first technical when talking about is if you get a file with something like this. Now this is a header and many files have headers. But if we run this program right now and we change, for instance, we would have to change this to 12 before we did it. But if we ran it, it wouldn't crash. But we would get Well, let me make sure that I have this right. So Yeah, so So let me save it first, cause I haven't saved it. But if we save it now, now it's saved and we rain it again. Now we get names up here. So we read in this, But But what if we don't want that? We don't want to populate our ray with this header. We just want to ignore it. Well, that's what we're going to do. We're gonna use a function called ignore. So let's change this back to 11. We're gonna go down here and before our pre read, we're going to specify with a function that we want to ignore that header. And to do that we use we access the function with our input stream foul handle, which was input file diet. Ignore, which is a function in this function, has two parameters that we need to use. The first is the amount of characters that we want to ignore, which is 255 and the reason it's 255 is because in a console window in a C plus plus application and the console window, there is 255 characters on each line. So if we specify 255 then it will ignore this whole line in the console window, and the cursor will be moved to right here. Right before is that and the other, the parameter that we want specifies What's Nosa delimit? Er? And that's a character that says, If you reach this character, then go ahead and start reading. Quit ignoring. And this is a new line character and later in this tutorial, we're going to go over this and debts because this is also a formatting advanced formatting option that I want to discuss with you guys. But this is a new line delimit er, which means, basically, if you get to the end of this line, you're going to reach a new line character. I want you quit ignoring because when you get to a new on character, you're gonna end up right here right before. Is that so? That's what the delimit er does. So now if we run this program again, what they ignore function in we only pick up the names that we want and it ignores the header just like we wanted it to. So moving on. And once you go ahead and memorize this function because he will be using it a lot more than likely with foul input. But moving on, we're going to discuss this guy right here. These special formatting characters. We're gonna do that here at the bottom of our main function. We're going to say something along a lot. Let's give us some space. We're going to say this is a new blind character and then we're gonna put several of easy in those air Three new lot characters, backslash in bets, Leshy and back slash in. And essentially, what we're doing is by putting these backslash ends in with our screen, it's not going to pre peas. These are basically the same thing is saying this, but instead we can just use the formatting character with the backslash in and accomplish the same thing. And if we run it, we'll see exactly what I mean. We get three new lines right here below our output because we added these new on characters . Let's move on to another example of these special characters that we can use. We're gonna use the formatting tab character will say this is a tad character. Then we're gonna we're gonna enter in four tad characters which your back slash tes will say tan and then a couple of backslash ends to give us some space because remember, those are the same thing as New line characters. And these are gonna be our tab characters and you'll see what I mean. In a second, we run it, so we run it and you can see all this space in between. Tad and this is a tap character, and that's where these backslash teas coming to play. So that's a special formatting option you can use. The other one that I want to show you is quotation marks will say This is a quote and we'll be back slash quotation. I will say quote backslash, quotation and then a couple of new on characters in the quotation marks. What this backslash quotation does is it escapes the stream and it puts these in because if we take out this backslash and it messes up our stream, so we have to have that in there and this is just a special formatting option. And when we run it, you'll see be able to actually have quotations and or output and says This is a quote and then have quotation marks. Quote. So that would be useful to you in the future whenever you need to use these escape characters and there's plenty more of them that you can use, and I suggest that you probably go try to look up some of them and see what you can do with this output. Okay, moving, going. I want to go ahead and discuss one more thing with you are. Actually we're gonna do a couple more things, but but one more with foul input before we continue. And that is we're gonna go named start txt. And what if we had something like Troy Hodges here? Troy Hodge is. That's the last name. And if we change us to 12 I'll show you what happens when we actually run this so we'll run it. And instead of saying Troy Hodge's oops, we need to say that girl quick before we do that. Okay, so there we have it saved. Let's run it one more time. Instead of saying Troy Hodges, it says Troy and then Hodges on the next line. That's not what we want. We want the whole name on this same line. But what's happening is in a file as soon as the scanner and gets to a white space character. It seems that that's the end of this of what we're reading and puts that into our temporary variable. So we mean what we need is a function that will read this whole line and put that in a single variable, and that's what we're gonna use. So just like we used input file dot Ignore. We're going to use another function called get line. We're gonna put it in our pre read and post re and the gate line function. All you do is type get line. You specify the input stream that you're using, which were using input file that we specified. And then you specify the variable that you want to hold the string in, or the line in which we're calling Tim. We're gonna do that for both of these will say, get line input, vile Thomas Tim that changes or are pretty reading Poe Street, where it reads in the whole line instead of just a single string value on when we run it, you'll see the difference. Now we get Troy Hodges on one line, whereas before it was, it was separated into two separate variables. Now it's holding this whole value in one index of the array. So that's the get line. Functioned and then the other one. Last thing I want to show you is what's called the Iot Manipulation Library, which is the input output manipulation library. And if you include that include I o minute. You can do some really cool things without, but and I'll show you what I mean. So we'll come down here and we'll say, See, out left, which specifies a left alignment. I will say set precision to to and then fixed. And what this does is a specifies left alignment. Set the precision to to, and what that means is that decimal values will only hold two places. Were any value for that matter. So if you have the number 200 it's really just gonna look like 20 because it's not gonna hold that other zero Well, what fixed does fix says, Take this set precision and Onley apply it to after to the right of the decimal place. So now if you have 200 it will hold the whole number 200 plus 2000.0 Or if you have 200.134 it will only hold the value 200.13 So let me show you what I mean. We're gonna make a double value to 1.792 and we gotta give had a name, we'll call it double value equals and then we're just gonna output that will say, see out in a couple lines will say double value. And when we do that, you'll see that we only get to a 1.79 and not to a 1.792 And that's because we used this Iot manipulation technique to set the position to To after the decimal point. That's exactly what we did. And one last thing I want to show you is what's called the set wit. So we're gonna go ahead and make another value called insecure. Value equals 7 227 And what we'll do is we'll say, C l. We'll give it give us a little bit of space. Well, say cl set w specify 25 which is 25 characters. Then we'll say double value and will say set never you again. 25 And we'll say integer value and wine and what this does. This sets the width to 25 between each value of output and you'll see what I mean when we run it. Now we get to a 1.79 a width of 25 characters and then 227. And then, if you if you print it out something again, you would have another width of 225 in between it because we we specified to put another one right here, and that's exactly what that does. So I suggest you play around with these advanced output and input manipulation techniques, and you'll learn that you can do some really cool things. So thank you for watching and state aimed 18. Practical Program #2: Hello. Welcome to Practical C Plus plus programming the beginner course. And in this tutorial, we will be building our second practical program. And it's gonna be primarily a council application that you could maybe use in several business environments, and I'll show you what I mean. So I already have a employee stock txt file with two headers, name and salary and then the employee list on top and in several employees names with their salary on the right and you'll notice that has their first and last name. So that's gonna be a tricky part with this program that we're gonna have to pay attention to. But the primary focus of this program is to be able to read in this file and then display the contents of the file in the console window. And no matter what, if someone goes in and changes this file, maybe throws in a another name, Jake Long, and then adds another salary to it. So we added, you know, 82,000 to the salary. Whenever this final updates, we want our program to automatically know that it updates and be able to add that name to the console so that means said, that's something that we're gonna have to really focus on is we build this code and, ah, afterward I'm building, get, really advise you to try and see if you can go in and use file output and falling. Put together to create a program using everything that we've learned and, ah, modify this program toe where you can maybe, you know, push the number one in it and you can add a name to the list. Or, if you push number two, you can delete a name from the list. It will constantly be updating this employee list foul, and the idea is for it to seem like a human resource Ah, program that companies could use to kind of update all the employees that are on their payroll. So that being said, let's continue on and let's start this. Let's start coating this So the first thing we need to do is include our libraries, and we know that we're gonna be dealing with fouls a lot. So let's go ahead and include that library, the file stream library and then the other library we want to include, since since we're gonna be printing out this data in the console window, we're probably going to be doing a lot of output manipulation. So let's include the input output manipulation library, which is pound include io minutes, if you remember from the last tutorial. So now that we have all the libraries that we need, we're going to go ahead and continue on to the main function and ah, and set up our file input, so to speak. So So we need to include our foul input handle with the input file stream, Um, declaration and we're just gonna call it input or we'll call it. We'll give it a different name. We'll call it Employees file and will say employees dot txt for the constructor. And ah, we'll go over constructors, maybe in a future class if I do in advanced C plus plus tutorial on, you know, classes and advanced data structures. But basically, this is this is a function of if stream and this is the constructor. And all we're saying is we want to create a file handle called employee file and we want this file to automatically be associated with this text file. And I know we went over that in the file input tutorial, but I just kind of want to rehash your memory about that idea. So then let's set up or checking function to make sure that this file was found. Employee file. Okay, we got to say C l employees text file not found well in the line a few times just so we could throw those in there and then we'll return. Negative nine. Let's go ahead and run it. Make sure we don't get any heirs and that the file is found and it appears that the file was found cause the process returned zero rather than negative nine. So we're good to go and then let's go ahead and set up some variables to hold this data. So let's make a string employees name variable, and then let's make an ENT employee's salary variable. And these are the two variables that we're gonna use. And since we don't know, since we're gonna make this program toe where you can kind of update this program at any time and we don't want to have to go in and change the size of our arrays were not gonna use an array, but instead we're going to actually use our output in or wildly that we used to read in the input and I'll show you what I mean. So the first thing we need to do after declaring our variables with this program is get rid of these headers because we don't want to save these headers in any string. And to do that, we're gonna use our ignore function. So we're going to say employees file dot ignore And then the 255 characters in the new land a limiter that's for the first line. So that's gonna ignore this this first line and employees dot txt. Now we need to ignore the second line. So we're going to say employees vile diet. Ignore 255 new on the limiter Cole and Cole and then the semi colon. So now that we've got rid of these headers, we can actually start a pretty read in our post Read are wildly and start a real being in this data and printing it out. So to do that, let's go ahead and comment pre read. We're gonna put in our pre read right here, but remember, we want to hold the whole employee name in one variable. So we can't just read in one name at the time. We're gonna have to read in all this at a time without actually picking up this data so we can't use get line and actually read in the whole data. We're gonna actually have to make use of our delimit er and stream size with the get line function. So let's do that now. So for a pre read, we're gonna say get line. Our employee file is our our is our input string. And then for the stream size where we need to Assane that no name is pretty much gonna be 50 characters long because that's gonna be a really that's gonna be a really long name. So I 50 character, Long would probably name would probably come all the way out here all the way to the beginning of salary. Nearly so we're gonna use fifties are stream size limiter pretty much and ah, but first we need to hold it into a variable. So we're gonna say employees name employees name is our variable, and then we're gonna put in our stream size, which is 50. And if we run that we shouldn't get an air. OK, so we do get in there. But we need to, and it's probably cause we need to delimit er and so we're just going to throw in a new on delimited because we shouldn't reach that. Let's see if that runs and it still doesn't run. So let let's look at a functions. Let me ah, go back real quick and let's see what we can throw in here for a delimit er. So we start out with the input based extreme basic stream input and then character delimit er. So I'm pretty sure that the only thing we can do is that the limiter on the get line and to do that, let's go ahead and say, Let's see if this works. If we just put in a delimit er on get line and that does work just by putting in a delimit er so I don't I don't think, Let me Atacama. I think you can Maybe I was thinking maybe you could add in a size, but apparently that throws an air so you can't throw in a size, could only throw in a delimit er so the delimit er that we're gonna use. Let's go ahead and do that. The delimited er that will use is a comma. Okay, that will be the delimit er that we use. And we're gonna update our text, file this employee text file to separate the names, uh, and the salaries with the Kama. So, you know, we can just be like this. It doesn't even but only had to be lined up correctly or anything like that. But we will go ahead and do that. So So we have these this text file, right? And I kind of went, Let's make it a little bit prettier, so that so that it looks nice. And we have these commas separating the names and the salary because the get lan function as right now, just off the top of my head doesn't use a string sized a limiter like the ignore function does. So I could ignore function. We could ah, we could actually put in a string size and ignore up to a certain point. But on this one, we're going to use a delimit er, which is the comma. So basically, what's happening with get line is is that we're using the employee file stream were storing the very the data in the employee named String Variable and all the data that we're storing in there is all the day All the data up to this, um, comma right here, which is what we said is a delimit er So let's save that. And let's, uh, throw in our wild leave now. So we're going to say, While no employees filed on e o. F function, let's go ahead and set up a post read comment function so we know where it is. Our post read. It's gonna be the same as of right now, um, to store our data is going to Samos hard pre read. So we're gonna store employees. We're gonna store employees name and then the the limiter of a comma and then a semi colon . But remember, the pre and the Post Street isn't complete yet because we need the whole name. And then we also want to store the salary. And to do that, we need to add something in our pre read and post read, and that's exactly what we're gonna do. So we're gonna extend or pre read by a line, and we're going to say employee file, use the input stream operator and then say employees e salary and the same thing with our post read. So say sorry about that employee file input stream employee salary just like that. And that concludes our pre read and post read. And if we run that everything should run find with no heirs and we're actually reading in all the data into a variable. But the thing is, we're constantly overriding the same variable because we don't have an array set up yet. Well, we don't need an array because we're going to actually print out everything that we need in this, um, while leap. So let's go ahead and do that. We're gonna say we're going to set it up. We're going to say, see out and let's actually set up a We're gonna go ahead and set up or input where everything works, just like we want it. So at the top, we're going to set up a how we're going to manipulate our output with C out left and then we really don't need a set precision and fixed because we're not dealing with decimal values. So we'll just say, see out, left up there and then right here will say set ever you and will say 25 and then employees e name and then set W 25. Actually, we won't even need that one since we're using the left and left orientation so it gets a set every 25 employees name. And then I think if we just say employee salary, that should output just like we want in Milan and let's see how that works. And there you go. So we have the name and then the salary and then a new on the name and then a salary and then a new line, just like we wanted. But let's make this a little bit prettier. Let's go outside of the leap and let's add some. Ah, let's add some output So we'll say. Well, say something along the lines of right here before our ignore will say, See out, um, tab a few tabs and will say employees or will say Human resource is human resource is payroll list and we'll end a few lines and then we'll say C L set W 25 four name and then salary, and then we'll end a few lines again on. What this output will do is we'll make it look nice and set it up for us. So we have full name salary. Okay, so but salary needs to go over more. And I think the reason why is because we have this Jimmy Clark and binge Minutes actually picking up all the data to the comma. So just the way it looks right now, even though we have the same wit, it's not the same because because of the length of these variables, they're actually ah, lot longer than just Jimmy Clark because it's storing all the white space up to the comma that we used. It's a delimit er, so let's just push salary out a little bit further. It's going to kind of be a hit, miss top thing. For now, we'll just use, um, 35 see, see what that looks like on 35. It's nearly there, right over the top. We'll just add, you know, maybe 37 see what that looks like. 37. Perfect. So we have human resource is payroll list and then we have the header full name and then salary, and then we have a whole list of everyone on payroll in their salary. And if we update this, employees dot txt file. I just want to show you so we could say, um, Jimmie Johnson And we're just Atacama will give him, you know, 100. And we were just given 13,000 will save it. When we run this program again, Jimmie Johnson will be added because we put everything inside or a while loop. And that's kind of what I wanted Teoh do for this practical program was kind of show you how you can update instantly just by using these variables inside the wild leave and not having to use a data structure like an array. So I want you to play with this. I want you to figure out maybe a better way to do it on your own. If you can kind of dive into mawr output manipulation and see if maybe you can Ah, you know, if we obviously if we changed the delimit er if we change the comma like let's say we pulled the comma of way to right here, you know, in in our text file, that should change exactly how are ah, program looks so Let me just show you that real quick before I leave. Because I want to show you that just by changing your text file, it's gonna actually change the output of your program since we're using Akamas a delimit. Er let me just fix this real quick. And since we're using this commas a delimit er the variable like on Jake Long, for instance, is actually this long, this many characters, and when we save it, you should be able to see the difference in our program. So you see how much shorter since are variable names were actually shorter, that these numbers shift over, and that's kind of wives want to show you. And that's why we had to push salary over to kind of, ah, compensate for that delimit er being the comma and how far over it was in the text file. So that's it for this tutorial. Stay tuned for the next section when we start discussing functions and actually make our hangman game. Thank you 19. Functions: Hello. Welcome to Practical C Plus plus programming Beginner Course. My name is Zak. And in this tutorial we will begin discussing advanced topics and C plus plus, um, mainly all we're gonna be dealing with his functions and how to use functions. And though many people may say this isn't really an advanced topic, I do consider it as an introduction to advance topics, because in C Plus plus, you will be using functions all the time. And they can get pretty complicated when you start throwing in templates and using, you know, structures as a parameter and passing by pointers and returning a pointer of a pointer. So basically, I consider it this going to be an introduction to advance topics and ah, that's that's all we're gonna discuss. We're basically going to discuss everything that we need to know about functions to get started and toe build or Hank Mann gain. So that being said, let's get started. Um, from the very beginning, with we've always had this main function and this whole thing right here is the main function as well as we discussed. But I want to discuss the the anatomy of the function so to speak. So So what is this end right here? Will that end me? Is the return value of the main function and a function can either have a return value where it can not have a return value and just be void. The main function always returns an integer value. And you can see that here when says return zero and we can actually return whatever we want . So let me show you. For example, we could return eight right here. And when we run, this program will say Process returned eight. Well, that's because the main function is returning the value. Eight. So what? That same token? Let's go ahead and turn it back to zero. And let's create our own function that returns the value. So let's say, um, we make a function and we're gonna call it, um, we're just gonna make our first function, is not gonna return anything, and then we'll make a second function. The desert turned something, So our first function is going to be void, meaning it doesn't have a return type. And to do that, you type void. We'll call our function. You can call it anything you want. We'll call it print. Hello. Put the parent disease. That's where your parameters go. We'll discuss parameters in a later tutorial, and then put your brackets. And since this is avoid function, there is no need to type return and then a value that will actually throw an air. If we do that, because the return type is void, meaning we don't need a return type. And this function right now, this code will run just as his, you know. And ah, that's all it does. All it does is basically return zero, because this function never gets called. But let's let's give this function some code to run so we'll run. See out. Actually, it may go down a line real quick will say see out hello and then in the line. But when we run the code, we still won't get hello printed on screen. And the reason why is because we have to call that function. And to call this function, you simply just type the name of the function in your main and your main function. So you say print hello at your prints, sees and then add your semi colon. And so the code will always start running with your main function, it will say So come here. And the first thing this code days is look up the print hello function, go to it and run the code in this. And then it's gonna return Void so returned back to the main function and they'll say Process returned to zero because they know we're on this code. When we run it, that's what we get. We get the word hello and then process return. Zero. This is back in the main function, so let's make let's make one more function. Let's let's make one that returns a number So we're going to call it it. Or let's say double, um, get age and we'll say it returns the age Well, we can actually say we can do one thing we can say return age, which we could say is 23 or were what we're going to do. We're going to declare a variable. We're gonna say double age equals 23.0, what a semi colon and then we'll say return age. Okay, and then let's make one more function. This says string get name and will return a string value return. Zach just like that. So you're seeing various examples of functions being declared here, and in these functions they're returning something different, and they're doing it in different ways. So let's go to our main function and see if we can use these other functions to make a cool message. So first will call print Hello, and then we'll say, See out. I will say, Get name And then we'll say is get age years old implied. And this right here is basically saying print. Hello. So it's going to call the function print Hello, which will just say hello, it'll in the line. And then it's gonna output, get named the function, get name, and when you call, get name, it's gonna return the value, Zach. Which means basically, when you call, this is gonna return the string Zack. And it's basically just going toe output Zach right here since we're using it in an output stream. So say output. Zack is get age. This one returns age, which is 23. So say Zach is 23 years old and blind and let's run it. And that's exactly what we get we get. Hello, Zack is 23 years old. So that's all there is to functions right now. And the future tutorials. We're gonna go Maurin depth with these functions. But for now, once you have practice using the ideas we discussed in this tutorial and I'll see you in the next lecture Thank you. 20. Parameters: Hello. Welcome to practical C Plus plus programming. My name is Zak. And in this tutorial, we will be discussing function parameters. Now, function parameters are a pretty simple topic once you get your head wrapped around it. And in the previous tutorial, we discussed functions. And, you know, we did something like this would put, you know, string, print, name. And, um, basically, we would just say, you know, string name equals Zach, and then we would say Return name. And then down here, we did something like C l print name. And when we ran it, we got the name Zack to appear in the console. Well, with parameters, you can specify in the main function of value that you want to pass to the function that you're calling. So meaning basically, if we go up here if we want to return a name that, um, you know, or any names specified and we can add a parameter right here that says, you know, data type string because the name is probably gonna be a string and we'll call it name, Okay. And then this function will return the parameter name that is passed to it. So here If we say see out print name, we have to pass it a parameter a string value. We could call it Jim. And when we run this, it will print the name Jim because GM is being passed as name into this function and it's returning the name, which is Jim. And as I say, we can change this to Sam. And then Sam will be printed just like that. And just to kind of show, you know, you can you can pass in multiple parameters so we could pass in age. You know, if and if we just ran this as it is, we would get an air because we have to pass in another value. Units will pass in 17 and then it will run. Obviously, it's still just gonna print Sam because we aren't doing anything with age. But I just kind of wanted to show you on introduction on parameters and how to use them and functions. So, you know, maybe let's let me do one more example before we move on because I want to. I want to kind of give you a little bit more insight on how to use these. So we're going to say, um right here will say string, print name and it will pass in the name. And then let's make another one called, um, and age will pass in. We'll call it get age will pass in a double. We'll just call it X. We won't call it a judge just to show you, you know, that this is user defined. You can call it whatever you want and will return X Okay. And then here what we will do, we will say, um, you know, see out, enter a name, Let's give us Ah, let's say string name and then devil Age will say Enter a name and then we'll say CNN name . And then c l give it a couple of new lines with our new formatting characters that we learned will say Enter a age bitter and age the end age And then we'll say, See out, Give it a couple of lines will say your name is well, Say, get name. Is that what we called it? What we call it? We call print name. Okay, we'll say print name will pass in name that we got from the keyboard input, and then we'll say we'll go down here just to show you that you can do this and see in code blocks you can. This is all gonna be seen. It's one line of code, even though it's on two different lines. So I'll say print, name and then and you are get age will pass an age that we got from the user input and we'll say years old, just like that, when we run it, I will say, Enter a name that name will be You will just say Jim Intern age 23. I'll say your name is Jim and you're 23 years old and that was the result of passing those values to these functions as parameters. So that's it on parameters. Stay tuned and we'll get to talking about passing by reference and function. Overloading. Thank you. 21. Pass by Reference: Hello. Welcome to Practical C Plus plus programming the beginner course. And in this tutorial, we will be discussing passing by reference. So what is passing by reference? Well, let's go ahead and make a few Mawr functions. Let's just make one function and we'll call it, Um, I will say void, um, a git or will say void print, age, print, age and will pass in an integer value called X. Okay. And, um, go ahead and put it here and let me go ahead and show you before we do this because I was going to save this for a different tutorial. But, um, let's go ahead and show it to you here right now. If we run this program. Everything runs fine, because print ages declared above main. But if we move this function below main when we run it, it'll run fine until we call it when we call it. When we call print, age, past of value, we'll get an air, and that's because, um, the code the main function starts running. It says print age. It looks forward up here, and it's not there. So what we have to do is we have to prototype it. So I'm gonna go ahead and show you how to prototype that All you have to do is up here in the under using name space. You just type the name of the function. So you type void Print, age, ex semi colon. And now, whenever it gets to print age down here, it'll come up here and it will look at the prototype, look it up and then say OK, I know this function exists. I'm going to go find it, and that's exactly what what it does. So we're gonna start prototyping are functions for now on using this method instead of declaring our function above main. So if we run it right now, you can see everything will work Fine, because we've prototype function now. But let's me vine Teoh what we actually came here for and that's to learn what? Passing by references. So we have this function called print age. What we'll do is we'll just say C l X and ah, if we if we run this if we say print age seven, we will see that it prints out seven. But what happens if we say, for instance, let's make a value it age equal seven. We pass in age, Okay? And then here it's gonna print out the age it would pass in. It will print out seven. OK, but what happens if before we print out seven, we change. X equals it's five. So now we just past seven in for X, but we change it. We say X equals five. So let's run that seen out Prince L five instead of seven, even though we passed seven into the function. Okay, well, what happens if we if we're changing it here? The question is, if we're changing it in this function for change, because we're passing in seven is it getting changed in this function? Well, there's one way to find out. We can print out age after we run it, and I see what we get. And so we get five and then seven. So obviously age is not changing, except in this function. Well, what do we do if we want to change age in this function? But do it in this function, for instance, here we're changing X equal to five. What if we wanted to change the value that we're passing in 25 as well. Well, to do that, we have to pass by reference. And what that means is instead of passing a copy of age into this ah parameter, we're gonna pass the memory address of age into this parameter. And to do that, you simply just type in the ampersand symbol before your variable name. So now whenever we run it, we have toe type in our prototype up here is Wells. Don't forget to do that. So now when we run it both equal five. And the reason why is because pull this back up so you could see both at the same time. So here were saying into age equal seven. And as we declared in the prototype and in the function when we pass age and right here we're not passing in the value seven were passing in the memory address that this variable lies that in memory. So now in this function, X is equal to the value at the memory address of age, which is seven, and it changes it to five. Well, that means it's also changing wherever ages at the value at age 25 as well. And so it's changing both the copy and the actual variable 25 So So let me see if I can kind of show you what I mean. And one more quick example before we quit, cause that's gonna seem kind of confusing to you. Maybe at first. So we're going to do one more. That's maybe a little bit more clear. So we're going to say, believe this function we just won't call it will make another function called Ah, void change address. Okay, we'll pass in a string and we'll call it. Oops, we're passing a string and we'll call it address. Okay? And we need to prototype it appear remembers that will say string change, address, string. And you actually, in the prototype, you can take out this eggs. It just has to know that you're passing in a stringer and it in the prototype so you could actually make the variable name. You know why here and ex down here and it doesn't matter, but it's totally up to you if you want to leave it there. Just so you have a same look going out through the same look going throughout your code, that's fine. But often just leave the value the data type and then the ampersand symbol. If I'm passing by reference in the prototype parameter and here I'll do the same thing. I would just say String Ampersand, Which means we're passing in a string memory address here in this prototype. And then we'll add a cynical and finished prototype. Now, in the change address function, we're going to say Address equals four 1800 College drive. Okay, and that's all it's gonna do. It's gonna take the memory address that is provided. It's gonna look at the value at that memory address, and it's gonna change it to this. So let me show you again. So we'll say String. My address equals 24 18 Willow Road and then we'll say, See out, address before function, call my address in plan and then we'll say, will say change. Address will pass in my address, which is really the memory address, the memory location of this variable, and then we'll say, see out address after function, call my AG dress. So even though the variable my address is being declared, here's 24 18 Willow Road and it's not being changed anywhere in this function. We're passing it to this function as a memory address and changing it in here. Okay, so it's changing to 1400 college drive, and when we return, it's gonna be different. So watch. So we have void. Change address. Let's see what went wrong. Here we have string address equals 1400 College drive. It's saying, um, old declaration. So let's see. Let's make sure our pro top is fine And right here is What's wrong? So we have we need. We had a string return top here. Let's change it to avoid and let's run it again. Address before function Call is 24 18 Will a row. But the address after the function calls 1400 college derive so you can see how it's actually changing the my address Variable in this function, and just to prove it to you, we're gonna take this out that ampersand. We're gonna take out this ampersand, and we'll run it again without the ampersand and look at the difference. It says. Address before function. Call 24 18 will erode actress after function. Call 24 18 Willow Road, and that's basically the basics of passing by reference. And in the next tutorial, we're going to go over function overloading. So thank you for watching 22. Function Overloading: Hello. Welcome to Practical C Plus plus programming. My name is Zak. And in this tutorial, we will be going over function. Overloading, um functions. Overloading is an interesting topic, and I found it pretty easy to understand. Once you get your head wrapped around, it's not too difficult. And even though we probably won't be using it in our final Hang Man project, it's still something I think you should know as a beginner so that when you see it, you understand what is happening. So what we're gonna do is we're going to make a function that says, um, you know, void print salary, OK, and this function is going to take in an integer value and will make that function down here void print salary it x Well, basically, just say C l in Dillon Eggs in Dillon. And if we run that, we'll get just what we expect will say print salary will say 20,000 When we run it, it'll just print out 20,000 which is exactly what want. But what happens if we want to use the same function? But we want multiple ways to do it, for instance, will say something like c l enter your salary and we'll say, um, you know, CNN salary and salary could be, for instance, we don't know if they are going to enter a string, um, salary or let well safe right now. We'll say it's an end salary and will pass in salary out here. So whenever they enter it, it won't get put into the function. So if they enter, your salary will say 23 country male pronoun 2300. But what if you know, we're having, You know, in this function, it won't really make sense because you have to declare your data type meaning whatever you declare, they're going to have to enter it anyways. But what if you have, Whenever you start programming an object oriented design and, um, different tops of programming architecture, you're going to see that sometimes you don't know what kind of data is coming in. And even though that won't be the case here, we're gonna pretend like it is so that you can go ahead and get your head wrapped around the whole concept. And so let's assume that someone enters in a double salary all of a sudden, and when we run it and we enter the salary, you know, they enter in something like that. Well, it's only printing out this because it was supposed taking an injured your value. Well, what if we really wanted to print this value? But we can't with this print salary function because it's on Lee asking for an interview value. Or better yet, what if we went into, uh, say double salary and Pesce in a string on when it says into your salary? Now it doesn't even run because you can't pass in a string at all. But what if we did want to pass in a string and have him type out $2300 as a word? Well, to do that, we can solve this problem about something called function overloading. And to do that you simply make multiple prototypes of the same function, but with different parameters. For instance, will say void print salary and we'll say stream will make two will make double, Then we'll say, avoid print salary stream, and then we'll come down here. Copy this, and we're gonna make we're going to reprint them, and we're just gonna change these so this one will take a string value, and this one will take a double value. Well, now we have the same function, but we haven't overloaded with different parameters, so we can expect pretty much anything to be inputted. So now, before, when we got an air when we ran this, we can run it again and print salary We can actually enter in 20 three 100 dollars. I'll say 23. And I know it didn't say $100 because, technically, we didn't do get line. We're gonna go ahead and fix that real quick just so I can show you. Um, and I know you've seen this before in the previous tutorial, but probably not with CNN. So we'll say CNN with get line instead of before we did something like output file or input foul. And then we'll store it in salary. And now when we run this, if we can say, you know, 20 three 100 dollars, I'll say $2300. But that same token, you know, we can change this to a double, and it will use that same overloaded function and before you will use this function and before whenever we used. So let's see What's going on here? Says See out, double salary prince salary function Call to double And I believe let's just try to do this , I believe get lines only gonna work with string values anyways. So lets say, salary. And when we run it, we will say 2300.246 or whatever or 0246 We run it and it will actually get the get the whole value. And though it didn't do four sixes, because right now it's on default. Value of double precision point is 0.0.2 after the decibel. That's where the double comes from. If we actually changed double too flow, which is the same thing, is the devil's. Basically, they're both decimal point values. I just with they take them different bites and memory when we run it. Um, see here to make sure we have we have a prototype wrong appear change that float. I'm just kind of showing you how to overload different tops, and data went into your salary. Now 2300.2345 Again, we get the same thing, and I'm thinking that maybe it's because it's defaulting to a floating a precision point of 0.0.2 Let's just check that out real quick. Let's say you know, see out, Uh, set precision toe four fixed and let's see if that fixes it. We don't have Iona nip involved, so let's go ahead and include that. Let's run that. And there we go. So now we're getting the four position point. So we had to specify to set the precision point of four after the decimal because it's defaulting to no matter whether it's a float or a double data type. But, um, needless to say, you know, this tutorial was more about overloading functions, and that's basically what we did. We can enter in now when we run it. I know that you see when we're running it, we know that it's a float coming in because we had to declare it here. But what I want you to understand is that in future classes we get in the object oriented programming. You may not know what kind of data is coming in, and that's where function overloading is important because oftentimes you don't know if a string or a float is going to be passed into a function. And so you have to prepare for were all scenarios. So that's it for this tutorial in the coming tutorials. We're gonna go ahead and start building our hangman game and conclude this course. Thank you for watching. 23. String Functions: Hello. Welcome to Practical C Plus plus programming. My name is Zak, and in this tutorial, we will be discussing string functions. Now, I just want to kind of go over this because this is something that you will be using the lot throughout C plus plus. And I'm not gonna be able to show you every string function, obviously, because that would be a whole video Siri's. But I will show you the ones that you'll probably find yourself using quite a bit. And all the string function is Remember what I told you at the beginning of this quarter's that string wasn't really a data top, but was a class well, without diving too much in the classes. Um, what a class is basically is a It's an object that you can create an object of the class, and that object will have specific functions. Well, without, you know, you might not be able to wrap your head around that just yet. I want to kind of show you what I mean. Each time you create a variable of top string, for instance, name equals AC. This variable has several functions built into it because it is type string that we can use . For instance, we can say, you know, name diet saws and that will return the size of the variable name. So if we say C L name diet sighs when we run that it will print out the size of name, which is four characters. At that same token, there's another function called name dot length, which will do the exact sending thing I'll print out for. So, like I said, there's several string functions that you can use. And if you look through you, all you have to do is tapping name diet and all these functions pop up you that you can see . And if you just play around with them, you know, you can kinda see uh, what they dio. For instance, let's just use fine. We'll use dot find and will search for C. And I believe if we see out that if it runs, I will return to because that's the position of sea in the string. Because remember, 012 And if we type in H here, if we find H, it will return three. And that's what the find function does. You confined certain characters throughout the stream. But if we top in a character that isn't in the string, such as Jay, should return negative wine or a value sections. This some kind of garbage value because obviously that's not a position anywhere in the string. So you could, for instance, type in why, and you'll get another strange value. So we get another strange value. And that's kind of how you can decide for whether the whether the character was found. Nine. So that's basically all I kind of wanted to show you. Was it? Each of these name objects has for each of the string objects. Variables have their own built in functions that you can use, such as find size, length, replace in. You know, they're all down here. You can kind of stroll through him, Look at all of them, but that's all I want to show you for this tutorial. I know it wasn't very much, but it's something I want you to play with on Rhone, and, uh, I'll see you in the next tutorial 24. Random Number Generator: Hello. Welcome to Practical C Plus plus programming. My name is Zak. And then this tutorial, we will be discussing how to create our own random number generator. Now all the random number generator is is it's a function that returns a random number so that we can use it in our program. And the reason why I went to cover this is because, believe it or not, this is something that many people like to figure out how to do so that they can incorporate it into games or certain programs that require some level of randomness. Now, if if you if you're just trying to kind of figure out how to make a random number on her own, you would have to kind of create your own algorithm and would be quite a lengthy process. So what I recommend doing as a beginner c++ programmer is any time you're looking for some kind of kind of functionality, like, such as randomness, for example, like we're doing here, I recommend going to C plus plus dot com as you can see up here and just searching for what , what you're looking for in this case, I topped in random and I ended up with this function called Rand, and you can see it here is called Int rand void. And if you kind of just looked through these documents, you can see how you can use the this library in these libraries to create a random number generator. And it's really quite simple. And they spell it out for you out here. How easy it is to get your program to spit out a random number. Well, about his random is you can get anyways, you know, all computers. There's no way to really make them completely random, but you can at least make it appear and, um, to the user. So that's exactly what we're gonna do. You can kind of mark this reference down if you want to come back and read it later. But basically, in this program, all we're gonna be doing is everything that this reference page tells us to do to create our generator. So let's go back to our program, and we're first going to include the libraries that we need for a random number generator to work, and that is include standard library dot H file and then include time dot H file. You might be wondering what this time dot h libraries for? Well, our random number generator is going to be based off the internal clock of the machine, and it's gonna incorporate that into its algorithm to come up with a random number. And, uh, you'll you'll see what I mean here in a second. I mean, it won't be extremely clear, but that's basically how this algorithm works, is it? It gets the current time down to the millisecond and throws that into a function. And basically, that function is going to spit out a different number every single time. Because the time is changing constantly and depending on what the actual time is, the algorithm may spit our completely different number than the one it spit out one millisecond ago. So that being said, let's go ahead and create a function that's gonna generate our number will have it return an integer value because we want to return an integer. We'll call it, generate random number and won't take any arguments. And then down here, we're actually going Teoh right out or function so well, right the same thing. Generate random number and then in here is where we won't rather toad. And if you go to C plus plus dot com and look at it, it's actually quite simple. You just write, include your libraries and then write this small function right here, which initialize is the random seed Teoh the internal clock on the computer. And then you just simply spell out your your variable with this function, with this number always being the number between zero and then on this number to be all your random values that are possible and then plus wine. And this will return any number. For instance, right here. This I secret variable will spit out any number randomly between zero and 10 because they have 10 specified. Right here. Let me show you what I mean. So the first thing we have to do is type s rand parentheses. And in these parentheses for the constructor you type the time and then another constructor is no and a cynical one just like that. That may seem really un intuitive at first, but that's what the C plus plus dot com reference tells us to do. So that's exactly what we're gonna do for a random number generator and on certain functionality that you might need in your program. It's not that important to understand exactly how it works. You just need to know how to use it. And that's kind of what I'm showing you right here. So this is how you would used the Raynham random number generator library with the time dot H and standard library header files. So now let's go ahead and hold a um, we're gonna hold a value will just return. There's so there's two ways to do this. You can create a value called yet, and we'll just call it number. I will set it equal to Rand, But you're constructor Modelo operator. The number between zero and fifth and zero and then X basically that you want the highest number to be will put 50 down and then plus wine cynical. And this number when this code runs will be any number between zero and 50 on a basically picked randomly. So for you return number there and then here we just return. We call the function, generate random number. When we run the program, the main will call that function and you see processor turned 41 because it's calling in this return function of the main is calling generate random number. And when it returns, the value returned from generate random number. He returned 41 but if we run it again, it'll give us a different number. This time it returned 50. But we can keep running this over and over again. And every time it will be a different number between zero and 50 and all we have to do. If we want to change the spread, we could change this to 200. For example, there'll be any number between zero and 200. This time it was 96. So that's how you use a basic random number generator. I just kind of wanted to go over it with you so that you would know what we were doing when we make our final project, and also to kind of show you what C plus plus dot com is and how to use it to incorporate certain functionalities into your program. So thank you for watching, and I'll see you in the next tutorial. 25. Project -Hangman (Part #1): Hello. Welcome to Practical C Plus plus programming. My name is Zak. And in this tutorial, we're going to start our Hank man game. Now, in all the previous tutorials who learned about everything that we need to know to build this game, And I'm gonna actually spread this game out through a series of three different tutorials so that we can split it up nicely. And, um, you can really understand how we're going to unfold this process and, ah, build the application as a whole. So in this first tutorial, we're just going to start out by billing, building the main skeleton. So to speak of our entire program, we're gonna lay out all our functions and everything that we're going to need. That being said, let's go ahead and prototype all the functions that we we know we're gonna need. So one of the functions that we're gonna need is to get a word from a word bank and return it so meaning Basically, we need a function that opens a file, looks inside the file and grabs a word, and then uses. That is the word that we're gonna try to use and ah, use. That's a word that we're gonna use for our hang meaning. So to do that, we're just going to call a function with the return type is string. We'll just call it, get word, and we won't give. It ain't parameters, because that's that's just gonna do its own thing. Go inside a word bank and get us a word. And since that's working with files, let's go ahead and include the library that we're gonna need for that that function, which is include F string for file stream. Okay, now we have that. We're also gonna want a function that the prince, the board, the board that we're gonna need when I say board I mean the man. So we're gonna want a function that prints out kind of a you representation of how many lives that the user has lift. And to do that, we're just gonna call it avoid return top because it's not gonna return anything. It's just gonna print out on screen something, and, uh, we're just gonna call it print board, and this is going to take an integer value and that integer values basically just gonna be the amount of lobs that we have lived because depending on the amount of lives that the user has left, um is going to depend how much of our of the man is drawn. So that's what that parameter is all about. And speaking of printing or board, we also need a function that Prince blanks. Uh, you know, Prince, the amount of Blank's for the word that gets returned. And so to do that, we're just going to call a function that also, since all it does is printing something, it's just gonna be void. Return tight, We'll just call it Print Blank's. And we're gonna give that we're gonna give that function to arguments. And they're both gonna be of type string because the the first parameter is going to be a, um, the word that we get returned here and the second parameter is going to be the letters that the user has already guessed. And that's how it's gonna determine what blanks to print. And, uh, what letters to print. And we'll go over all this and the you know, as we go through these tutorials, go see exactly how it's gonna work, okay? And, ah, let's go ahead and make another function that generates random number because we're gonna use the random number that we generate to actually decide what word to grab out of our word bank. And we already did a random number generator tutorial. As you know, So this should be fairly familiar to you. We'll just call it, generate random number and cynical. And so these are prototypes that we're gonna use if I remember a function that we might need If we decide we want to create another function, we will. But for now, these are all the ones that I can think of off the top of my head that we're gonna need. So that being said, let's go ahead and ah, set up these functions so we'll say, you know, string, get word and set up or brackets. Then we'll set up a void print board, and we'll call it lives for the parameter. Avoid print blanks, and that's going to take two parameters. 1st 1 we'll just call it chosen word. And the 2nd 1 we will call letters guest. You'll see exactly why we're calling him that later, and the last one was our random number generator, and that one didn't take any parameters. So there we go. So this is the basic skeleton. Now, I also want to go ahead and add some stuff to our main function while we're here. And the way our main function is gonna work, we're gonna go ahead and initialize are our use. Your lives will call it user lives to seven. And then basically, we're going to say, Wow, use your lives is greater than zero. We want to do this, anything inside this leap. And basically this loop is just going to allow the It's just gonna allow the user to keep guessing letters as long as the lives are greater than zero. And then we'll set a break statement in there somewhere. If the if the word gets guessed correctly, then we'll do that. So But that's how we're gonna set up our main for now, and we'll add more stuff later. And the other thing that I want to go ahead and do is since we it's kind of fresh in our minds, go ahead and make our random number generator while we're in this tutorial. And to do that, all we do is say, you know, string or my bad. I was had the I had that get word on my mind. But the random number generator we just have to include to libraries. If you remember, one was standard library dot h, and the other one was time H. There were those of the two robberies we need. Now, let's go ahead and make a random number generator. We're just gonna say s friend time. No. And remember, this was the This is the function that we need according to C plus plus dot com and their reference that we used. And then we're going to say, um, we're pretty much just going to say return. And you know, there's two ways to do this. Um, you could say return rand percent. And then I don't know how many words we're gonna have in our World Bank. We'll just say we're gonna have 10 for now, 10 plus one. And ah, this right here will return an integer value random, insecure value right here if we do that. So that's what we'll do there. And we might have to come back later and change, In fact, just for tow, avoid the confusion. What we're gonna do is say, random number equals rand and you make this integer and random number equals rand. Ah, Markkula Operator 10 plus one. And we'll say return random the number. There we go. And if you see if we go up here and we, um let me just comment this out real quick. Actually, I can't do that. Sorry. This is another way to comment, by the way, is with the store backslash just like that. That's a new way of doing it. Just to kind of explain that. Let's go ahead and test a random number. Will say returned. Generate random number. And just make sure it's given us a random number. And it's not, Let's see what's reference. Generate random number J green number. It's gonna make sure thank you. Right. There we go. We called it random number. Generator. There were probably screaming at me whenever I called it. That s so we called it. Generate random number. There we go. And it says process returned. Three. Let's run it one more time. Process returned. Three If coincidence. There we go. Processor. Turn on. So we're getting a random number every time. And while we're in this tutorial, I want to go ahead and ah, I want to make us a word bank And, uh, back of them actually in this one. And we have employees, don't text he let me delete that real quick. There we go. And let's just make us a new a new document, Star Command. We'll just call it a word list. Txt. We're gonna open it. Well, word list. Txt. There we go open. I will just say no. Give it a header. We're list. We'll give it a couple of nights, you know, Words. So we'll say draft Rhino. Um Reavy, um you know, truck, um cricket grass Hopper Buzzer. Just thinking a random, you know, words off tough my head. There's not really a theme going on here. That's yummy. That's 12345678 Let's get to more will just say, Oh, Taito and one really good word. I will say it, Lennox, There we go. That's 10 words. Not really a overall theme there, but it's the 10 words will use Forward bank for now. And ah, let's go ahead. And in this tutorial, go ahead and make our get word function. Since ah, you know, following putting falling output. It's kind of a thing. We've been practicing for a while, so we'll go kind of quick. We need toe. Go ahead. Make are variable. Call it if stream format that it will be better if stream will call it input five, then wordless dot txt and ah, we'll know pretty much since this is returning a string. Well, no. Well, say, ah, you know, if not input fireable will print out on air, but we won't return because this is a stringer. Turn time. So we won't actually be able to return a an insecure value here anyways. But we'll say, you know, air Negative six. Um, you know, word lists not found, that will, uh, that will let us know, at least if the word list wasn't found, and then we'll say, Let's go ahead and make another variable here. We'll call it temp word, and then we'll just say so. Uh, probably an agent. Well, yeah. Temp. Where there we go. Ah, and actually, we're gonna need an array, so we'll say a string Garay. Um, we'll call it word lift or Ah, yeah, we're just called word list. And let's go ahead and make a constant value. Const. In word list, size equals 10. And you can put a comment here in the code to let you know, you know, change word list size here. Just let yourself No, later. You know, if you make a bigger word Maine. Now, if you want change it to 100 all you have to do is had 100 right there. We'll say we're list wordless size equals just initialize the whole thing, Teoh blank strings. And then, since we're gonna need a four Lee, we'll use this index variable set to zero because we're gonna use a four leap later in this function and that. So that's what we're gonna go ahead and do now we're going to a pre read and we do have a header. So don't forget about the header that we need get rid of. We're going to use our ignore function So we'll say input, file, die, ignore or 255 bites. And then our delimit er of nuan that will get rid of the header, remember? And then we'll do a ah pre read commented there just for habit. We'll say input. Final camp word and then are wildly, we'll say, Well, not input. Fouled on u F. But I didn't make a post read. Same thing, remember is the pre read input file temp word. And then we're going to store everything that we get from this viable into a word list or word list. And to do that, we basically just say we're going to use our index variable that we created up here. We'll just say a word list index has got started. Zero where list index zero equals temp word. And then we'll say index plus place and then down here. Once this loop is done, basically it's gonna populate our entire word list array with all the words in this word list. So what we can do is, since we need to return a string value, but it needs to be a random string. From our word list. We're gonna use a random number generator or generate random number function to return a random index of this array and ah, return a random word. And to do that, all we do say, return word list and then for index, since it needs to be ringing them will say generate random number. That's our function generate random number semicolon. And it will return a random index of this word list which is populated with these words. And just to kind of show you that if we go up to our main function here, we were returning a random number before we'll go ahead and put that back to return. Zero. We're just going to see out, get word and make sure it works. If we do that, we get the word blue. If we run it again one second that save it, we run it again. Oops. We get the word truck. Now we get the word linens so you can see we're getting We're getting new words every single time, Revie All from our word list, grasshopper. And that's how our hang me in game is gonna function. You know, it's gonna grab random words from this word list, and that's pretty much all I want to do for this tutorial. In the next tutorial, we're gonna go more in depth with printing our man and printing the blanks. But ah, I want you can go through this tutorial few times. And really look at this. Get word function and see how We're using this function in conjunction with the generate random number function to return a string of a index of this word list and, ah, you'll find it's actually may be a lot more simple than you were at first thinking. So thank you for watching and I'll see you in the next tutorial. 26. Project -Hangman (Part #2): into practical C plus plus programming. The beginning course. My name is Zak. And in this tutorial, we will be continuing or Hank Mann application. So and this tutorial, I've kind of already got the print, um, print board, um, code already program. And the reason why I went ahead and did it is because you really don't want to sit here for 25 minutes and watch me code out all this. You know, nitty gritty stuff that basically you can do on your own. All I'm doing is using my formatting tab operators. And I've kind of drawing out with these, you know, standard characters, this Hank Mann guy, and you can see as the lives the way I did it. The way I programmed it was in this function takes printer of lives, and I use a switch case. And as the lives go down to zero, the man is fully drawn, but is the lives go up to five. You know, the man isn't fully drawn. He's only halfway John. And when he has full lives, there's no man there at all. But basically, I mean, it's really easy code. You just you can draw it however you want. But for those of you who just want to use this, you know, I would say, Study it a little bit, but not too much because it's pretty simple stuff. It's just you can you can customize it yourself. You know, you could make it bigger if you want or whatever, but this is the way that I usually do it, and I will provide this code for you. And the resource is tad of this lecture so you can actually download this code and just copy and paste it into your program if you want, because, like I said, topping it, Alice kind of a hassle. And, uh, but if you want to do it yourself, that's perfectly fine. So it's up to you. But what I do want to do in this tutorials work on our print blanks function. And it's actually pretty simple function that's just gonna print out the blanks and in the letters of each word that we use. And, uh, we're gonna have to use quite a bit of our string functions that we discussed in a previous tutorial. Teoh, get what we want out of this print blanks function so to begin, All we're gonna do is create a four leap integer I equals zero. And then I was gonna be less than the parameter chosen word. And all chosen word is is gonna be a word from our word list that was chosen by our you know, our get word function with the generate random number generator and whatever word is chosen , we're gonna pass into this function has chosen word. Yes, we went I to be less than chosen word dot size. And remember, this was one of those string functions that we talked about in the previous tutorials. And then we'll just say I plus plus and open our four leap. And now inside this four live We want two things to happen. We went, If the if the chosen word If the letter is in debts, you know, zero of the chosen war, let's have the first letter of the chosen. Word is a and A is in the any of the indexes of letter guest that we want to print out a on screen. But if it's a is not in any of the indexes of letter guest, then we want a print of blame so to do that, we're gonna use more string functions. And what does say if we're gonna use letters? Guest dot find? Remember, this is a string function native to all the stream data types or string objects, and we're gonna find the letter of chosen word don't at I And what this is saying, this function, it's it was going to be really complicated at first. But these air all string functions that kind of told you to study and, ah, the earlier in this section and all its saying is we're gonna get this string, this word, this list of letters and we're gonna look in it. We're gonna find to see if this letter, you know, chosen word at I that's just gonna return a single letter. So if this is chosen, word dot at three is going to return the fourth letter of this chosen word. So if the chosen word was, you know, buzzard, it would return. Or let's say, let's say the chosen word was truck. Then an index I was three is going to return is going to return, see, because three is actually 0123 So it's the fourth letter which return, See? And all this is saying is find in letters guest John C. And if it's found that story turned something other than negative one. But if it's not found, it's gonna return negative wine. So to kind of determine whether it was found or not, We just say letters get stopped, find chosen word dot at I not equal to negative one. And that means it was found as long. As long as this operation doesn't return. Negative one that we know the letter was found somewhere in the function. And so this if statement is saying that the letter was found and so all we do is see out chose word dot at I Well, I had a space at the end of it just to give it some spacing. And that's just saying, you know, output. The letter, um, this word, it a certain index. So really, study that, And then the alternative will just say else, because the alternative is that it was negative one, which means it wasn't found it all. If that's the case, we want to print out a blame the space at the end, uh, to give it some space So you know, this is alternative. This means that the letter wasn't found in letters, guest. So we're gonna leave it blank. And that's all this is This is all there is to dysfunction, and if we can actually test it real quick, so we'll save this. Let's go up to our main function and let's test it. So we're gonna say, uh, you know, here we go. Main function is up here. No, we'll say, Well, go ahead and say string. Um, word equals Get word. Well, well, output where? Girl quicks at the top of the screen so that you know what the word is. But then I also want to run print, uh, print blanks, and we're gonna pass inward as the chosen word. And then let's just pass in some letters ourselves will pass in r S t l n e think those the most famous will fortune letters. So these air the letters guessed that we're saying our guest and if we if we run this program, we should get no errors. And ah, hold on. Stop working. If we run this program, here we go. The word was Lennix and since in was one of our letters. Guest. Uh, we get we get the letter in now, you might see that ILL is capital Ill. And we had el here. That's something I need to fix. Obviously, I think I have capital letters in my word list. So we're actually gonna change that? I'll change that in between tutorials, because obviously that's a bug in our program because we want we want this. We want all our words are wordless to be lover case because whenever we enter, you know, lower case ill. That's not going to show up because that's Capitol Hill, even though it should be there and s. So let's go ahead and run it one more time. Just show you so truck, You know, as you see the are was there because we haven't are the tea wasn't because this is a capital T in truck. We have a lower case t. So I will have to change that small bug and there's a way to get around it. You know, if you can check, basically say if you know if it's capital letter Lower case letter counted anyways, fill in the blank, but you just have to add more code. And if you want to do that, then I challenge you to go ahead and do that. But that's a basic functionality of print blanks. And while we're here, we're gonna go ahead and, uh, take out the comment of our while. Leap and let's go ahead and add some. Let's go ahead and add some basic stuff, too. So we'll say. Since we have all our functions planned out and everything that we need, we can basically go ahead and add the rest of what we need to this loop and all that is is basically say, you know, uh, print board will pass in, use your lives, which is seven. And then we'll say, Let's give it some. Let's give the user some instructions. I will say See out. You know, give it some new ons and we'll say, Uh, well, first of all, we we want to tell him what letters have been. Yes, I will say letters guest. Let's actually create a string for that. We'll say string letters. Guest equals Well, say, see out letters, guest letters, guest. There you go. Now they can see what letters have guessed, and then we'll say I'm see out, Um, enter a letter. Oops. Sorry, guys. It's the inner letter. When will you see? End? Well, say, um, straining. We're just calling. Guess. Well, so I see on guess There we go. And that right there were basically So we're just telling them what they've guess. We're printing out the board, which is gonna start out as a clean board. No man hanging from it. No letters. Yes. Will say in her letter will enter the guests. And then what? The first thing we need to do is say letters guest plus equals, Remember? That's just gonna add a string to it will add Guess to it now, Letters guest is gonna have a guess in it. And then ah, we need to. Well, first of all, we need to get our words. So that's another thing we need to add real quick. So let's say I will say string word equals get word there. I guess Now I have string where it equals Get word. And that's basically just gonna return. Remember, that's gonna return a word for more word bank. And we got a story inward, and then we need to do is print blanks and we actually want to do that before this. So we'll say Print board. And then we'll say, Um, now, let's give us a little bit of space and will say um, print Blank's I will say a word Letters guest that'll that'll print out all blanks the first time letters, gas plus equals guest. And then basically, if we want to check and see if But if it was in it. So let's go back now to do print blanks. Actually, I think we can actually do that in here. Yeah, there we go. And there we could add that end if we want. But actually, let's just go ahead and do that appear. We're gonna do that in the main function, but you could do it and neither one will say letters plus equals. Guests will say if, um I will say if you know word dot find. Yes, does not equal mega for Boyne continue, and basically this is just going to continue more into the loop and then we'll say else because this means that they got the got the guests right, and then it's automatically gonna update it will say else lives minus minus or I think we called it. Use your lives. User loves minus minus. There we go. Let's go ahead and run that and just make sure everything runs okay, So if you look at that, we got our four blank printed out are hanging man Elsa in her letter Hostess Interim are there We go and it goes ahead and draws it. If we enter in, let's say, B, we don't get calls. Another one to say l look, it adds it to our blank e There we go E ads for blank you b and C The world was blue, but, you know, obviously there's still some bugs because it's not letting us know when we win and keep going. I think, until we can enter multiple letters, no process return zero because our lives went out and, uh, we just fix a few things. Few minor things to make sure that who knows if it zero will print out of our full guy? But ah says that's pretty much we wanted to go over in this tutorial. I want to go ahead and add one more thing that you haven't seen before, and that is at the end of the at the end of each. Before we continue in each of these statements, I'm gonna add it line it says System CLS, which tells the console to clear. And it'll actually make our game look a lot better. So we will see what I mean. When we run it again, let's go ahead and run it and it'll say So what's Inter in the G and is you could see it's not running down the screen anymore like it was the last time. That's because, um, when we when we clear the screen, it's reprinting it all in the same exact spot. So it looks like it's it's not going anywhere. That's the kind of effect that we want That system CLS is something new, but something easy and something that you can use in order applications. I just want to go ahead and show you that. So in the next tutorial, we're gonna completely finish it up and then test job or application and conclude our class . So thank you for watching and I'll see you in the next tutorial 27. Project -Hangman (Part #3): Hello. Welcome to practical C Plus plus programming. My name is that and this is our final tutorial. So in this tutorial, I've kind of already topped up and fixed everything that we needed to fix. If you look are wordless dot txt you can see I changed everything toe lower case So we don't have any conflicts with our user input And, uh, the word that has chosen and ah to in order to what we really need to add was in order to decide whether the winner whether the user has won or lost during each gas And to do that, the first thing I had to do was declare a global variable called flag. Now, I'm not sure if we went over global and local variables, but all the global variable is is a variable that is declared outside of all the functions you can see I could not. In the main function, this variable has actually declared underneath all my prototypes and what this does it is. It allows this variable to be used in all of not functions across the board. Now, this normally isn't recommended. You definitely don't want to do this with all your variables for privacy reasons, but in this case, it's gonna work out perfectly for us. So I created a Boolean variable called Flag. You can name it, whatever you want. Values called it flag. And I declared it too false. For when the program first start starts up, it's gonna be declared false. And then if we scroll down a little bit in our wild leap, you can see that I have the flag set to true right at the beginning of the while loop and then I have a condition. This says, if flag equals true break. So I kind of want to show what this is doing. This is basically on the program when this wild loop starts setting flag to true and then after these functions run the flag is still true. It's gonna break from the while loop and I want to show you where this flag would get changed and that to my print blanks function. So let's go down to print lengths. I'll show you what happens. So in my print blanks function, all I did was I basically said that if this branch is executed, set flag to false. But if this branch never gets executed at all. Flag is going to stay true because every time this four lube runs is gonna be running this piece of code rather than this piece of code which basically means that throughout the life cycle of this four loop, if one blank gets printed, the flag is going to be set to false basically meaning that the puzzle has not yet been solved. Flag equals false meaning. The word has not been completed yet because they're still a blank. But let's say this four loop runs all the way through and not one blank gets printed. Then flag will never get set to false. And if we go back up to our main function, flag never gets set to fall. So flag is still true. After print blanks, it says a flag equals true break. What? That point if you break, you come out here outside the while loop and I added these two conditional statements. And basically it says, If use your lives equals zero, then obviously you broke out of this function because use your lives was zero. And if you recall, are wildly basically said, while use your lives is greater than zero keep doing this. But if usual lives equals zero, then break out of this function and come down here. And if you come down here after you break out a function with usual live zero, then you're going to run this code and it's gonna say you lose. The word was and they will tell you the word. But if you use your lives is greater than zero, then obviously you broke out this while loop in a different way, which was via the flag. So let's say use your lives is at three. Flag is set to true print length runs. No bread, no blanks were printed, basically meaning all the letters were guessed correctly. Flag is still true and you break out of this wild loop. Well, then you're breaking out. This wild loop while usual lives is three diffuser lives is three hence greater than zero than this code is gonna get ran instead of this code, and it's gonna say you win. And that's basically the functionality of this code. It's actually rather simple because basically, we just created one more variable, and we just we basically just you have to think about it a little bit. You know, we came down here and we just set the flag to false. If one blank got printed, basically a blanket all gets printed in the flag is gonna be false, and you will never be able to break out a while loop, Uh, be a the If statement checks that flag is true, you won't be able to break out. And the only other way breakout is if lives is equal to zero. And if laws equals zero, then you lose. And, uh, so that that's how this works. And if we run it, I want to go ahead and show you our finished product. When we run it, we'll go ahead and well, so this first word just cause we have 10 words and I kind of ran it a few times. I know what it is is linens. So, you know, let me get a couple of letters wrong. So it's starting to draw her main, and you can see, but if But if we get it all the letters, right, so we'll say I in you, x, and you can see it's telling us the letters that we've guessed, which is something I want to add in and they says You win. The word was Lennox Process return zero and you can see that that's how the game works. But let's run it again. I think we actually have the same word. No, we did. So this is a different word, not Lennox, because it picked a different word out the World Bank, and we're gonna try to get it wrong. So we'll just guess random letters. You could see it's drawing our man and more and says You lose The word was truck, and that's the basic functionality of this program. It's a basic hanged man game, but we used literally, you know, everything that we could and this course and so everything that we learned we got to utilize for this program. And that's kind of why I picked this project for end of the course final project. And so what I challenge you to do is is, you know, kind of convert this program into something more advance may be used file output or something else that we learned in this course, you know, to save high scorers, maybe use a word bank with 100 different words and then, you know, use the foul output to say, You know, each time you run it to save your score to this vile and then check with the high score is in that file and then print out with the high score is compared to your score and keep updating that file every time you run it. I would recommend trying that and just really getting good at thes beginner concepts and run through this run through these last few tutorials a few times so you can see how we use these functions. Because when you take an advance C plus plus scores, you're gonna have to be Ah, you're gonna have to really know all that stuff really well. So the last thing I ask is, if you really enjoyed this course and you learned a lot is to give me some good feedback and maybe leave a review if you can. And if you really, really locked it, you can. You can leave a review and just kind of tell me, you know, your doctor see an advanced course and I'll get enough people interested. I will definitely make an advanced course, and we'll do some cool. We'll do some more cold projects. But for now, thank you for watching and thank you for being a part of this course Goodbye.