Main Content

Staring a C course with Hello World - why?

Archive - Originally posted on "The Horse's Mouth" - 2010-06-30 07:25:34 - Graham Ellis

Every programming course starts with a "Hello World" program - that's a program which does no more than print out the words "Hello World" when you run it - truely minimalist. It's not just convention that courses start that way - it's also very sensible as it allows he tutor to teach the delagates how to edit files, and to get from a file of source code to a runnable program. (Diagram, right - click on it for an enlargement)

For our C course yesterday, I called by "hello world" file greeting.c, and edited the source code in with my favourite text editor. You can see the source code [here]. I then compiled up the code with gcc to make a runnable file ... which I ran:
  gcc -o greeting greeting.c
  ./greeting

You'll note that there's more to this in C than in languages line Perl ... in C, you need to add a reference to the header file (to prevent warning messages, anyway!), and you need to define the action within a main function. I have also chosen to "start them young" by commenting my code. Not strictly necessary, but very much needed once your code starts to grow!

Coding is all about efficiency and code re-use these days ... so I went on to demonstrate the calling of a function in C [here] and the loading of a function from an included (header) file - see original file [here] and included file [here]


We offer no less than 4 courses that include C ...

[link] to learning to program in C. For delegates who are new to programming. Covers C and not C++.
[link] to C Programming. For delegates with prior programming experience in another language. Covers C and not C++.
[link] to C and C++ Programming. For delegates with prior programming experience in another language. This course carries on to cover C++ which adds object orientation to C.
[link] to learning to program in C++. For delegates who are new to programming. This course carries on to cover C++ which adds object orientation to C.