• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Caleb Curry

Making Money and Investing

  • Home
  • Make Money Online
  • How to Buy Bitcoin
  • Get Started with Real Estate Investing
  • How to Start a Website
  • Courses
    • Full Time Income Online
  • Sponsorship

C Programming Tutorial 48 – Good Coding Practices

November 8, 2018 by Caleb Curry Leave a Comment

In the last blog I spoke of How to Write If Statement with Boolean Variables.  Check the one out first! Are you new here? Start at the beginning, Intro to C!

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!

Filed Under: Uncategorized Tagged With: c programming, good coding practices

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

my face to show my face

My name is Caleb Curry and I started my online business teaching software development and doing digital marketing for brands. Entrepreneurship has changed my life and has allowed me to earn a full time living from anywhere. I now have the freedom and energy to pursue skills and opportunities that I find interesting. This website is all about my journey.

Get my top Python Tips and Tricks

50+ Python Tips and Tricks!

Subscribe to our newsletter to get notes and latest content by email.

    We won't send you spam. Unsubscribe at any time.

    Follow Me!

    • Instagram
    • YouTube

    Recent Posts

    Copyright © 2021 · Genesis Sample on Genesis Framework · WordPress · Log in