• 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 3 – Writing Our First Program – Hello World

October 17, 2018 by Caleb Curry Leave a Comment

Check out the last blog: C Programming Tutorial 2 – Installing GCC! You won’t regret it. 😉New here? Start from the beginning! 

In this blog we are going to write our first computer program. If you are new to programming, you should know what a Hello World program is. Essentially, a hello world program is a program that says “Hello World” on the screen.

The point of this is to have the confidence that you have all of the proper tools installed, everything is set up correctly, you’re able to write the most basic program, compile it, and execute it. Essentially, a Hello World program will take you from beginning to the end of writing a program.

Let’s Make a Program!

The very first thing we have to do is create the file that we are going to write all of our code in.

The .c at the end of the file is called a file extension. The C means that it is a C file. Make sure you end all of your C files with .c!

Now once we have the editor open, we want to start typing. VIM has different modes, so we actually have to switch to Insert mode. Press i.

Now, you can start typing! To get out of insert mode we can press the Esc key.

Now to move your cursor around in your program, you can use your arrow keys. Later on we’ll learn some more fancy tricks to navigate, but this is a great way to adjust to using VIM as it’s very similar to any other text editor. Just don’t tell anybody I told you that!

Let’s go back into insert mode.

Now basically everything I type in this video may be new to you. That is ok!! In the next video I will go over what everything means and by the end of this series this will be a piece of cake.

Once your program is done you can exit vim while not in insert mode by typing:

This will write your changes to disk and then quit.

Compiling

Now, we need to compile:

Now, let’s take a look at the folder we are in by typing:

You can see that we have hello.c, and a.out. a.out is the executable that gcc created. We can now run this to see it in action. To run the program type:

The ./ is to say that we want to execute something in the current location, and then the name is all we need to run the program.

There you go! Congratulations!

Conclusion

Now, if you’re not so lucky, you’ll have some problems with your code and the program will refuse to execute.

Always try again! Just remember… if at first you don’t succeed, don’t try sky diving!

Do you like these blogs? Check out the next one on how a C program works!

Filed Under: Uncategorized Tagged With: c programming, hello world, writing out first program

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