This video is going to be a very short and to the point video that explains some good habits that you should have when you are starting out programming.
Let me tell you, a lot of people hate programming. I believe one of the reasons for this is because they don’t follow what I am going to teach you in this video.
The very first thing has to do with code indentation. Inside of every block, you want to indent every statement. The very first code block in our code brings us back to the main function. The main function is the function that is executed when we run the program. This is our first code block, so everything needs to be indented once.
Personally, I use the tab key to indent. If you prefer, you can use spaces. I don’t really think it matters. Some people get into arguments whether you should use tabs or spaces and I’m just like…does it really matter?
If we have an if statement, we are creating a second code block. That means everything inside of the if statement needs to be indented.
Additionally, when you start making some kind of larger structure like an if statement, it helps to type out the outline first.
Then, go back in and fill things in. This helps you remember to close anything you open and to have the right structure.
When working with quotes, always open and close at the same time.
Remember that c is whitespace insensitive, so you are allowed to be flexible on how you write things…but you need to be consistent. Don’t do some if statements like this:
and others like this:
Follow conventions you can find. I’m following conventions of camel casing when it comes to variable names. Whatever you choose, be very consistent.
When doing comments, always put the comments either below or above a line of code you are commenting about. Either way is fine, just be consistent. I tend put comments on top.
Ready to learn more? Read the next blog on relational operators!