0:00 what's going on guys? This is bucky and this is the second c plus plus tutorial 0:04 and in this tutorial what I am going to be doing is breaking apart 0:09 this computer program that we ran in the last tutorial so if you remember 0:13 whenever we first created a project in code blocks 0:16 Code Blocks already made a very simple computer program for us to run and test out 0:22 just to make sure everything was working and all that it was it printed out hello 0:26 world 0:26 on the screen. So if you go ahead and build and run this we see that 0:30 it just says hello world and some other computer stuff that 0:33 isn't really relevant. But anyways all this computer program does 0:37 is print out hello world and before I get into breaking this apart and telling you 0:42 what each piece does I want to say one thing you would 0:45 think since computer programs are just made up of a bunch of lines of text 0:50 that we can learn each line 0:53 one at a time but computer programs are weird in 0:56 that this is pretty much the most simple program you can write and check it out 1:00 there are already 7 different lines 1:03 included here so in order to even really most basic program 1:08 you need to code at least seven lines of code. So it seems kinda confusing and I just wanna 1:13 just give you guys a warning. As long as you can get through this video 1:18 all the rest the videos are going to be incredibly easy 1:22 this is the only one where have to throw a bunch information at you 1:25 but so, I'm gonna break it down is easy as possible. 1:29 Uh, and the reason for that is because you need so many things in order to run 1:33 such a simple program 1:34 but once you understand the basics everything else is just smooth sailing. I 1:38 promise. 1:38 So, let me go ahead and we're gonna be getting more in-depth 1:42 each of these lines. But, for now let me give you guys a brief introduction 1:46 to what each line does. Let's go ahead and get started talking and work our way down. 1:51 This include iostream line right here, 1:54 this is technically called a pre processor directive. So, you you are taking a 1:59 test to be watching these 2:00 tutorials because you know maybe you're in C plus plus class and 2:03 your teachers kinda confusing you. Answer on the test 2:07 this is a preprocessor directive. Now what that means and 2:11 everyday terms is it pretty much says alright 2:14 we're going to be including a file in this program that we're going to be 2:18 using later on 2:19 so it's gon be including a file iostream 2:22 that we didn't make. we didn't make this file, but it needs it to run this program 2:26 later on. So that's why 2:28 you needed to include it. Again we're going to be talking more about header files 2:31 later on but 2:32 for the basics of this tutorial, all you need is that 2:35 to know that this line includes a file that our program needs to use 2:40 later on. Now, the next line you can see 2:43 is just a blank line. You may say alright "Do you need this blank line Do younot need it?" 2:49 like lines and spaces you can have a million of them if you want 2:53 or we can have none of them just like that. all blank lines do in programming 2:57 is they make the program easier to read. So just as a book or magazine 3:02 our newspaper sometimes you want blank lines between your code. 3:05 Sometimes you just might go right under each other. It's personal 3:09 preference. 3:09 Um, people you know whatever you want blank lines just make it easier to read 3:14 so whatever's easier for you 3:16 at as many lines or less lines as you want. And that brings me to another point 3:20 these tabs too. see this is kinda tabbed out or tabbed in and 3:24 it's the same thing some people tap things and make easy read 3:28 this program just gonna run just fine if it's just like that 3:31 but you know people just like the line certain things up so you'll see later on 3:34 once we get coding 3:35 that taps and spaces and blank lines they don't really mean 3:39 anything significant they just make the program easier to read so that being 3:43 said 3:44 under that link line is this: "using namespace STD" 3:48 and believe me it on this does not stand for sexually transmitted disease. 3:52 I like to think that, but trust me doesn't. It stands for the standard 3:57 library and that's another thing that is built into 4:00 C plus plus. That is pretty much same as we're going to be using 4:05 all the standard things with C plus plus. Nothing fancy. Again, 4:09 we're going to be going over libraries and stuff in the future but 4:12 basically these two lines include things that we will need later on. This includes file 4:17 in this includes something called a library. What you know. 4:21 It is just a bunch of C plus plus stuff. So, with that being said we know that these 4:25 two lines 4:26 include things. fair enough. so now let's get to the meat 4:30 and, I guess, meat and potatoes I guess other 4:33 computer programming and that's this. this entire thing 4:38 is called a function. now of computer programs 4:41 are made up a functions and all functions are are 4:45 things you want the computer to do. for example whenever we're making programs 4:48 later on. 4:49 We're going to make a function to play sounds and we're gonna make a function 4:53 to draw graphics on the screen 4:55 and as you can see functions are just things that you want the computer 4:59 to do. So every computer program 5:02 starts with a function called "main" this is how your computer knows 5:07 where to start. So for example, in couple tutorials we're going to have a function 5:11 called main 5:12 and like I said we're going to have another function called 5:15 "play a sound" and are going to have another function called "make a ball" 5:19 bounce around on screen 5:20 and you going to have all these functions and your computers going to say alright. 5:24 You me all the stuff to do but how do I know order to do them in? 5:28 Well your computer automatically knows 5:32 anytime it runs a program to start with the main 5:36 function so that's why it's so crucial to name this function main. 5:40 So, in order to make a function you do this. You first write 5:43 what type of data you're going to be working with 5:46 and functions typically do is 5:50 to do some sort of calculations, for example find body mass index or 5:54 calculate the velocity or something, well whatever makes his calculation 5:58 it usually wants a number back, an answer in other words. 6:02 Well since we're going to working with just integers, main always 6:06 works with integers. so that's why we need that but again we'll be getting into 6:09 that later on 6:10 after that is the name up the function in this one is named main Um, don't worry about these parenthesis right now but what we do need to worry 6:18 about 6:18 is these little..., are a semi colons 6:22 squiggly brackets, ugh, I guess work out curly braces 6:25 I don't know whatever the heck they are.In this 6:28 has an opening and closing curly brace and in between on 6:32 you have something called statements. now all functions are made up of statements 6:36 and all statements are basically instructions 6:39 and each instruction needs to end with a semicolon. that's why you 6:43 every line inside a function ends with a semi-colon. 6:47 for example if you had a function that says 6:51 make peanut butter jelly sandwich one statement would be 6:54 get out bread, the next a man would be put butter on a piece of bread. the next statement 6:58 would be put jelly on piece of bread. 7:00 The next putting together. the last put them in your mouth. 7:04 BAM. you now have a function and a series of statements. 7:08 well all this function did. the main one said, perhaps something on screen 7:12 and return 0. Simple enough, so now you can see the basics a function 7:17 how they're made in how every function needs to include 7:21 statements or instructions. So, that being said, let's break this down 7:24 even more. the first statement is saying this. 7:27 first from the COUT thing right here. That's called an output 7:31 stream object and it's basically used to write characters on the computer screen. 7:36 that's how we are able to type hello world on the computer screen. 7:39 so this is always used in conjunction with this. 7:44 this is called the stream insertion operator. This pretty much takes all the 7:48 stuff to the right of it, 7:49 and print it out on-screen. I mean this is 7:53 just saw. you know it's weird symbols but 7:56 that's ok whoever made C plus plus they decide to use these were symbols 7:59 to print out something on screen. why they did that, you have to take it up with 8:03 them 8:03 by anyways this is basically how you pronounce up in screen 8:06 so this prints out hello world and then 8:10 this pretty much just means END line, or go to the next line. 8:14 so this line right here is pretty much the same print something on the screen 8:19 now this last thing I want to talk to you guys about is called 8:22 the return statement. now usually like I said 8:26 functions will calculate something like body mass index or velocity 8:30 and when they calculate it, it's going to want an answer back. so, 8:33 if I had a function that calculated my weight, it would return 8:37 155 or 160 depending on if I ate tacos or not today. 8:41 well the main function should always have 8:45 return 0 and return 0 means 8:48 whenever you return 0, it tells your program that it ran fine without any 8:53 errors 8:54 for example if he had a buncha actually text right here. your computer program 8:57 would give you an error. 8:58 and it would never get to this line right here so and never return 0 9:02 so whenever it does get to this line, it means everything above it 9:06 ran fine. in return 0 means your good to go. 9:10 main ran fine. so I know that was a lot of information 9:15 to get you guys for just your first tutorial, but again like I said, 9:19 every computer program starts with a buncha stuff that you need to know. 9:22 And we are going to be covering each more the topics in depth but for now I just want 9:26 to give you guys a basic understanding 9:28 of how a computer program is made. so if you don't understand everything completely 9:33 then don't worry 9:34 you're not alone you will in future, I promise. But for now 9:37 thank you for sticking with me and I thank you for watching this tutorial. 9:40 and I can't wait see you next tutorial. and if you have any questions 9:43 forget to check out my website the newboston and com and 9:47 yeah are seen next video