C Programming Tutorial 4 - How a C Program Works - Part 1

submitted by mkenny400 on 03/19/18 1

The goal of this video is to break apart some of what we wrote in the last video and to understand some more concepts.   The way a C program works is by writing out what we want the computer to do in very specific terms. Imagine that the computer is super dumb and you have to write down every single instruction. Imagine you are a computer and I told you to like this video. Seems simple enough, right? WRONG! If you were a computer, I would have to really spell it out. I mean reaallllyyy spell it out. This means that to tell you to like his video the instructions might look something like 1. Move your hand to the mouse, 2. Grab the mouse, 3. Move the mouse until the cursor hovers over the like button on the screen, 4. Click the left mouse button.   The idea of explaining everything in detail is called an algorithm. This is an algorithm to like to my video. Now, I want to modify the algorithm a bit so that it can be used to like any video on my channel: 1. Move your hand to the mouse, 2. Grab the mouse, 3. Move the mouse until the cursor hovers over _________ (video). 4. Click the left mouse button. 5. Move the mouse until the cursor hovers over the like button on the screen, 6. Click the left mouse button.   Another thing to realize is that computers don't remember have a memory quite like we do…. I mean they are really dumb. This means that to tell you to like another video, I have to repeat all of the instructions. This means that there are essentially 12 commands now. 6 for the first video, 6 for the second. What if we could just take all of these commands and extract them as one command? Well, we actually can. This is known as a function. Let's create a function called likeVideo().   likeVideo(){ 1. Move your hand to the mouse, 2. Grab the mouse, 3. Move the mouse until the cursor hovers over _________ (video). 4. Click the left mouse button. 5. Move the mouse until the cursor hovers over the like button on the screen, 6. Click the left mouse button. }   Now, each time I want you to like a video, I can just say likeVideo(). This is called calling or executing the function.   What are the () for? That is where I tell you what video I want you to like. likeVideo("C Programming Tutorial 10"), for example. This thing I'm passing in is known as an argument.   Now, what if I added to the function steps for you to look at how many people have liked the video and ask you to tell me. So I give you a request, and then you return a number to me. This is known as a function return.   Why am I telling you all of this? Well in C, we start every program with a function called main. When our program is run, the main function is executed.   In the next video we will be discussing more specifics about the code we wrote in the hello world program. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support me! www.patreon.com/calebcurry Subscribe to my newsletter: eepurl.com/-8qtH Donate!: bit.ly/DonateCTVM2. ~~~~~~~~~~~~~~~Additional Links~~~~~~~~~~~~~~~ More content: CalebCurry.com Facebook: www.facebook.com/CalebTheVideoMaker Google+: plus.google.com/+CalebTheVideoMaker2 Twitter: twitter.com/calebCurry Amazing Web Hosting - www.dreamhost.com/r.cgi?1487063 (The best web hosting for a cheap price!)

Leave a comment

Be the first to comment

Collections with this video
Email
Message
×
Embed video on a website or blog
Width
px
Height
px
×
Join Huzzaz
Start collecting all your favorite videos
×
Log in
Join Huzzaz

facebook login
×
Retrieve username and password
Name
Enter your email address to retrieve your username and password
(Check your spam folder if you don't find it in your inbox)

×