Thanos Stantzouris Industrial Engineer & Web Developer

Welcome Duthcoders, this is my first time writing on a blog, so please be gentle!
Having that said, let's get to it!

In this guide i will show you how to write your first program in C and be happy with your lives, but before doing that i firstly feel the need to explain to you the reason why i chose C to be the debut of this series of blog posts about programming.

Well you see, the coolest way to analyze the logic behind this choice is by giving you an analogy : You can make your own bread with a prepackaged mix, a bread machine and some electricity or, you can assemble the raw ingredients, a mixing bowl, a stout spoon, a dough blade, fire up the oven and get some cardio through kneading. If your goal is to just eat bread as soon as possible then the former is the way to go.

But if you want to clearly understand the whole process that has to be followed and have more options while creating the final product, you need to put in the effort of the manual method. This is exactly what it feels like when programming in C, you, absolutely, have to get your hands dirty, oil them up and be prepared to always tackle absurd bugs just because you forgot a semicolon ( ; ). And i mean ALWAYS!!!

As the title is "Starting with C" and not "Why every Programmer should start with C", i will not go on and on about why i chose C any further and i will just dive into giving you the tools and your first C junk of code!

Note : This guide concetrates on the Windows operating system for 2 reasons.

  1. I don't own a Mac, therefore, who am i to tell you what to do on a Mac ?
  2. The guys who run a linux distro as an operating system already know what to do! (LINUX MASTER RACE!).

 

1st Step : Download and install an IDE.

IDE stands for Integrated Development Environment and is a software application that provides comprehensive facilities to computer programmers for software development. ( WikiPedia Info ). 
My favorite IDE is Code::Blocks, therefore this is what you are downloading. Deal with it!

Follow the steps :

  • Go to the Downloads Page and click the black link that says " Download the binary release "
  • Download the option that is 4th, from the top - down, " codeblocks-17.12mingw-setup.exe ". This step is very crucial! We need to download that option because it also installs to our system the mingw compiler
  • Double click the downloaded exe and install Code::Blocks.

 

2nd Step : Fire Up Code::Blocks.

Now that we have successfully installed our IDE and our Compiler we are, at last, ready to begin our first Console Application Project!
So let's begin.

  • By opening codeblocks you will see an option saying "Create a new project". You guessed it! Click it!
  • Now you have a pop up window on your screen with a variety of choices from ARM project to Matlab Projects. What we want to click is Console Application. And then press the Go button on the top right of the window.
  • Click the little box that says "Skip this page next time" and presss next.
  • In this Window we choose what Programming language we want to use! The available choices should be C and C++. Click C then Next!
  • Before naming your project, i would recommend creating a folder named "My Programming Projects" or something like that, in order to have all your Projects organised! Trust me on that one! Assuming you have listened to me, navigate to your folder by clicking the little button with the (...) on it and then name your First Project! Let's call it "Hello World". Press Next and then Finish!

 

3d Step : Code and Run!

We have reached the finale of this guide. Let's retrace our steps. By now we have downloaded and installed the Code::Blocks IDE with the mingw compiler, we opened it, followed the necessary steps and we are finally ready, both psychologically and technologically, to code our first console application!

  • What we should be seeing at the moment in our screens is the main development Code::Blocks Page.But it's blank! No worries, everything is as it should be!
  • On the left of the page there is a Management sidebar with our project's name on it! Double Click it or click the [+] button next to it.
  • A folder appeard named Sources, that folder contains all of our projects files. Double Click that and then double click the main.c option that appears!
  • Now the Page is not Blank anymore! We are greeted by this junk of code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
        printf("Hello world!\n");
        return 0;
    }
    

    Let's modify it a bit, just to say that we got our hands dirty with code, and write :

    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
        printf("Goodbye Cruel World!\n");
        printf("I am about to learn Programming...\n");
        return 0;
    }
    

     

  • In order to run the program we press Build and Run, [the little button with the Gear and the green play button on the toolbar]!

Now we should have in our screens a cmd like window with the results of our program!

 

4th Step : Feel happy and rejoice!

Well done, you are a class A nerd! But hey, it pays well and also don't forget smart is the new sexy !!!

Thank you very much for reading through! I hope that this guide will help you and make you love programming as much as i do!
You can show your support by liking our Facebook Page ! Support our efforts on Ko-Fi ! And you can get in contact with us either by sending us a message on Facebook or via the e-mail on the footer of the Page!

Thanks again! Have a lovely day... Or night!