Exercises, examples and other material relating to training module C201. This topic is presented on public courses Learning to Program in C
, Learning to program in C++
, Programming in C
, C and C++ Programming
In C, all code is written in functions and in
this module we write the simplest possible C function
to display the words "Hello World" on your screen. We
also have a first look at the compilers and linkers
(also known as loaders) needed with C to convert your
code from English-like text into a runnable program.
|Articles and tips on this subject||updated|
|3917||BODMAS - the order a computer evaluates arithmetic expressions|
What order does a computer program use to evaluate expressions? If I write
2 + 3 * 4 + 5
does it start off, left to right ...
2 + 3 is 5
5 * 4 is 20
20 + 5 is 25
No! it does not, even though the newcomer might think that was the most natural way for ...
|3591||Integer types, and integer overflows, in C|
C offers you the ability to define a whole variety of integer types:
short int my_number;
long int my_number;
typically occupying 16, 32 and 64 bits of memory (but that is NOT a standard, and you may find different on some systems). And the amount of ...
|3278||Do I need to initialise variables - programming in C, C++, Perl, PHP, Python, Ruby or Java.|
Starting with a clean slate. Are variables initisialised, and if so, how? Even with this fundamental question, languages vary considerably.
C and C++
From my (e)mailbag ...
"""In a piece of code we’ve written we declare an array, but we do not fill the elements with values, we assume (dangerous ...
|3234||Your program - you just provide the filling in the sandwich|
You may think (and say) that you're writing a program ... but you never write a complete program these days. What you do is to provide the filling to the sandwich - the bit that changes from one application / requirement to the next, and you then make use of standard surrounding material - the bread.
|3120||Learning to write good programs in C and C++ - separating out repeated code|
From our "learning to program in C and C++ day" yesterday - that's how we started our working year in the training business in 2011. "Learning to" courses, where we take people through the basic coding principles and concepts and in the language they'll actually be using are both the hardest work to ...
|2842||Staring a C course with Hello World - why?|
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 ...
|2576||What does const mean? C and C++|
If you declare a variable to be a const, you're telling the compiler that it's a read-only variable and that it won't be changed throughout its existance. A values that's passed in as a parameter to a function, for example, will be left alone until the function exits. That does not stop you from deriving ...
|2005||Variables and pointers and references - C and C++|
If I have a variable called "weight" that contains a float, I can use and set its value by using that name.
If - in C or in C++ - I declare a variable to be a pointer then that variable may contain a memory address ... I use a * in my type declaration, and then I use & in my assignment:
|1671||Compiling C programs with gcc - an overview|
Gcc - the "Gnu Compiler Collection" - is used to compile AND to link C language programs in an open source environment. A single command - gcc runs a series of phases that take you from source code through to an executable program file, with the actual steps taken works out based on:
• the extensions ...
|888||Turning C from source to a running program|
With scripting languages (or near-scripting languages) such as shell, Tcl, Perl, Python and PHP, the developer just edits a file of program code, and tests it - the tools that he uses roll the translation of his source into something that can be run without him having to make further inputs. C is somewhat ...
Examples from our training material
|first.c|| First program and some comments|
|hello.c|| First C program|
|makefile|| makefile for C version of "hello world"|
|second.c|| Commenting code in C|
|t2.c|| What happens when you overflow|
|tara.c|| Sample function to illustrate inclusion|
Some modules are available for download
as a sample of our material or under an Open Training Notes License
for free download from http://www.training-notes.co.uk
Topics covered in this module
"Hello World" - shortest program in C.
Compiling, loading and running a C Program.
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule
Well House Consultants specialise in training courses in
. We run
throughout the UK (and beyond for longer courses), and
at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if you live in a different
country or continent to us
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre. Also
available is the Opentalk
Forum for discussion of technical questions.