C Programming Tutorial 9 – C Basics Part 1 – Variables, Expressions, Statements

We started off our C programming with the hello world program. Before you move on, you really want to familiarize yourself with this basic structure. Don’t freak out if you don’t have it memorized, that is ok.

The point is not so much to memorize it because that will come with time. Just have a rough idea of where to put what and where semicolons go. Also know that the spacing is not a concern to C. You can say that C is whitespace insensitive.

The next few videos are going to be designed to give you the basics of C programming. These basics are kind of going to be various pieces of information that are going to help you, but I’m not going to go in a ton of depth. That’s because after we go over the basics I am going to go in depth in very many topics. I want you to be able to start working with C and not have to wait till you get to video 50 to know how to do some of the most basic things.

The first thing I am going to introduce to you is the concept of a variable. Now, the chances are you’ve worked with variables before either in some programming language or in math. We can create a variable in C very simply.

int x;

This is called the variable declaration. We are saying that the type of data we want to store in this variable is in integer. That means any whole number. Additionally, this entire line is known as a statement. A statement is when we tell the computer to do something. Think of it sort of like a command to the computer. There are tons of different kinds of statements, a variable declaration is just one type.

We’ve declared this variable. That means that it exists, but how do we give it a value? Giving a value to a variable is called variable initialization. We can initialize a variable like this:

x = 10;

The x is the variable, the = is called the assignment operator, and 10 is the integer we want to assign to x.

Now, anytime we use the value x, image just replacing it with the value 10.

Also, a very important word to know is syntax. This is the format of each command we can do in a programming language.

We can also do math in C.

int y = x/2;

This shows two important things. First, we can declare and initialize a variable in one command, and two, we can use the variable x anywhere the value 10 would be appropriate. This will give y the value 5. The way I think of variables is as a box containing some value. So we are putting the value of x/2 into y. That means if we were asked the value of y, we would say in this situation it is 5. Not x/2.

We could just have easily done int y = 10/2. The problem with this though is that if we use x a lot, we are not always going to want to use the value 10, or we might not always know the value of x. In this situation we are giving a value directly to x, but there will come a situation when we might ask the user for the value x.

The last thing I wanted to teach you in this video is the concept of an expression. An expression is anything that can be evaluated to one value. For example, x/2 is an example of an expression. This is an important because variables can only contain one thing. Whatever expression you give it must be evaluated. You are going to hear the word expression all of the time.

In the next video we are going to learn about outputting the value of a variable into the console when we run the program.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Support me! http://www.patreon.com/calebcurry

Subscribe to my newsletter: http://eepurl.com/-8qtH

Donate!: http://bit.ly/DonateCTVM2.

~~~~~~~~~~~~~~~Additional Links~~~~~~~~~~~~~~~

More content: http://CalebCurry.com
Facebook: http://www.facebook.com/CalebTheVideoMaker
Google+: https://plus.google.com/+CalebTheVideoMaker2
Twitter: http://twitter.com/calebCurry

Amazing Web Hosting – https://www.dreamhost.com/r.cgi?1487063 (The best web hosting for a cheap price!)

Comments

maxwell,cpp says:

are you planing on making a low level c programming tutorial ?
i know this is not the appropriate place to ask, as this is a tutorial for beginners

Ghillie The Goat says:

Marvelous vid, left a like and a sub =D

User User says:

I don’t know that much about programming but damn, this guy seems pretty good.

Smoked Robot Pâté says:

short, sharp, and sweet. bravo

哈桑 哈桑 says:

that is really great job. Thank you so much.

Men On A Mission with JAMES ADAMS says:

Keep up the good work thanks a lot, your work will be well known to many people just stay at it and don’t give up…

Lawrence Pellegrini says:

I can’t get past the as my system is saying that “No such file or directory compilation terminated.”

Smoked Robot Pâté says:

oy vey

Write a comment

*

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles▷ Show Cars▷ Motorbikes▷ Scooters▷ Bicycles▷ Rims & Tires▷ Luxury BoatsFashion▷ Sunglasses▷ Luxury Watches▷ Luxury Purses▷ Jeans Wear▷ High Heels▷ Kinis Swimwear▷ Perfumes▷ Jewellery▷ Cosmetics▷ Shaving Helpers▷ Fashion HatsFooding▷ Chef Club▷ Fooding Helpers▷ Coktails & LiquorsSports▷ Sport Shoes▷ Fitness & Detox▷ Golf Gear▷ Racquets▷ Hiking & Trek Gear▷ Diving Equipment▷ Ski Gear▷ Snowboards▷ Surf Boards▷ Rollers & SkatesEntertainment▷ DIY Guides▷ Zik Instruments▷ Published Books▷ Music Albums▷ Cine Movies▷ Trading Helpers▷ Make Money▷ Fishing Equipment▷ Paintball Supplies▷ Trading Card Games▷ Telescopes▷ Knives▷ VapesHigh Tech▷ Flat Screens▷ Tech Devices▷ Camera Lenses▷ Audio HiFi▷ Printers▷ USB Devices▷ PC Hardware▷ Network Gear▷ Cloud Servers▷ Software Helpers▷ Programmer Helpers▷ Mobile Apps▷ Hearing AidsHome▷ Home Furniture▷ Home Appliances▷ Tools Workshop▷ Beddings▷ Floor Layings▷ Barbecues▷ Aquarium Gear▷ Safe Boxes▷ Office Supplies▷ Security Locks▷ Cleaning ProductsKids▷ Baby Strollers▷ Child Car Seats▷ Remote ControlledTravel▷ Luggages & Bags▷ Airlines Seats▷ Hotel Rooms▷ Fun Trips▷ Cruise Ships▷ Mexico Tours