 How's it going everybody? Welcome back to C++ Programming. I'm Rudolf De Null. In the last video we were looking at inputs in our programs and our C++ code. In this video we're going to take a different route. I'm going to create a new file. Go ahead and save mine as 0.6. And I'm going to call this one functions.cpp. You can see that that's a new file that I've just created. And we, of course, want to include iostream so we can display things and that sort of thing. I use namespace standard. Let's go ahead and create our main function, which will happen automatically. And we'll return 0 at the end. I keep forgetting to do that. All right. Now let's actually talk about this concept. This is really, really simple. This is really, really easy. And I'm going to be getting into more iterations of this concept as we progress through, I think, a few more tutorials. But for now, this is the very, very easy, very, very simple way to create a function. You notice that this main, this code block right here, is a function in itself. This is the name of the function. The name of the function is main. It takes parentheses to refer to the fact that it is a function. Everything inside its code block is actually the things that happen because of this function. It takes a type, though. It's an integer function. It will return at the end of the function's execution an integer. That's what this return 0 does. So that's the basic skeleton for how a function is set up. Now, if I wanted to have, okay, let's create an integer function that says, um, say the number, actually, I'll call mine something stoop, return 4. And use parentheses to refer to the fact that this is a function. And what if we simply return 4? Now, if I go back to my main function, I use C out, and then I actually run return 4. The value that is returned from this function, which in this case will be 4, is going to be outputted to the screen because of C out and L. Okay. I'll go over to my terminal. I'll just show you very, very simply how this works. Let's use 0, 6. Oh, I'm getting an error here. Standard and L, C out. What's the problem? What did I do wrong? Oh, I see. Over here, when I say using namespace, I said using namesaps. Sorry. Okay. Now let's run the code. Head back to our terminal over here. Run this code. It executes, we've got 4. Awesome. This can be obviously anything. It doesn't have to return 4 despite the name. It can return 30. We run this code, it returns 30. Sweet. But it will have to return whatever is actually the type of this function. Now, what if we had any functions that we don't want to return anything? Well, that's a special type. In fact, we call that type void, and that means that it won't return anything. If I leave this line here, if I leave return 30, we might get an error when we try to compile this. Let's check it out. Yep. Yep, yep, yep. Cannot convert return 4 type void to type constant unsigned character, which, you know, is not a string that we would normally want to see in the C out, especially if we're returning 30. That's just not supposed to happen. If we return nothing, this shouldn't do anything for us. So let's change up the code in the main function. Let's say return 4. Actually, let's change the name of this function. Let's just say say hello. We'll call this function say hello rather than return 4. We'll just change the name and a file to go ahead and type C out. Hello. And L. Now remember, I'm not returning anything because this is void. There is no return type for this type of function. Let's run the code. Hello. No errors. It runs the code just fine. And it's the main function which is started automatically by our program is going to call the function say hello. And inside the function say hello, all we're doing is saying hello. Very, very simple. Very, very easy. That's all it takes. The only reason I really created what this video was to let you guys know the form of a function. We have the type, a space following that we have the function's name. Then we have the actual parentheses that refer to the fact that okay, this is a function. We have the brackets and the braces that okay, this is the code block. This is what the function actually does. And then the insides of the function, which is what the function will actually do. So that's the form that you need to know. That's how it all works. That's how you can build your own functions. Now, in the next video, let's expand on this. Let's have functions with arguments with parameters that can do specific things to a specific set of data. You see what I mean? We'll get to it very soon. But for now, thank you for watching, guys. Simple stuff, simple C++ code. We're going to get into more fun things as we roll along. For now, we're just steam rolling through the basics. Thanks, everybody. See you in the next tutorial.