
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 present, and the most rewarding to the tutor when (s)he sees the results, and I'm delighted we've added these extra days to the front of many of our courses, even though they require me to commit my bank holiday or Sunday to training a small group.
We started off with "Hello World". All programming courses seem to do that - and it's an excellent idea as it's the minimalist program which shows how a program is edited, compiled and run in the source language that's being taught in class. I then expand the "hello world" example to add multiple outputs, outputs from calculations, variables, and inputs too. Yesterday's example went one step further - adding in a conditional too, where King Arthur decided whether to pay in cash or to charge his Excalibur card.
[source].
Repeated code should be put into a loop ... and code that's likely to be reused from multiple places in a program should be put into a named block called a function. And that's what I did in the second major example of the day - that's
[here]. A further expansion splits the function(s) into a separate file
[here], the main code (for this first program) remaining in a different file -
[here], and with a separate header file of templates to tell the compiler and loader how the various components of source are related to each other / what parts of the compile will be satisfied later by the loader. Header file example
[here].
Courses mentioned in this article -
Learning to program in C++ and
Learning to program in C. These courses run at our Melksham, Wiltshire training centre and are intended for delegates with little or no prior programming experience. We offer other courses for delegates with prior programming experience who wish to learn C or C++ - see
[here].
(written 2011-01-04, updated 2011-01-08)
2560
Associated topics are indexed under
Q100 - Object Orientation and General technical topics - Learning to Progam [4008] Reading and checking user inputs - first lessons - Ruby - (2013-02-17)
[3895] Flowchart to program - learning to program with Well House - (2012-10-14)
[3551] Some terms used in programming (Biased towards Python) - (2011-12-12)
[2973] Learning to program - where to start if you have never programmed before - (2010-09-28)
[2898] Programming Standards from the start! - (2010-08-02)
[2505] I almost put the bins out this morning - (2009-11-16)
[2504] Learning to program in ... - (2009-11-15)
[2326] Learn a new programming language this summer. - (2009-08-06)
[2294] Can you learn to program in 4 days? - (2009-07-16)
[2286] New to programming? It is natural (but needless) for you to be nervous - (2009-07-14)
[2092] Tracking difficult bugs, the programmer / customer relationship - (2009-03-20)
[2048] Learning to program in PHP, Python, Java or Lua ... - (2009-02-19)
[2001] I have not programmed before, and need to learn - (2009-01-19)
[1985] Learning to program as a part of your job - (2009-01-10)
[1963] Best source to learn Java (or Perl or PHP or Python) - (2008-12-28)
[1605] Learning and understanding scripting programming techniques - (2008-04-08)
[116] The next generation of programmer - (2004-11-13)
C201 - C and C based languages - C Language Fundamentals [3917] BODMAS - the order a computer evaluates arithmetic expressions - (2012-11-09)
[3591] Integer types, and integer overflows, in C - (2012-01-25)
[3278] Do I need to initialise variables - programming in C, C++, Perl, PHP, Python, Ruby or Java. - (2011-05-05)
[3234] Your program - you just provide the filling in the sandwich - (2011-04-08)
[2842] Staring a C course with Hello World - why? - (2010-06-30)
[2576] What does const mean? C and C++ - (2010-01-15)
[2005] Variables and pointers and references - C and C++ - (2009-01-23)
[1671] Compiling C programs with gcc - an overview - (2008-06-10)
[888] Turning C from source to a running program - (2006-10-06)
Some other Articles
C++ - putting the language elements together into a programC++ objects - some short, single file demonstrationsWhen is a program complete?New year, new C CourseLearning to write good programs in C and C++ - separating out repeated codeTransWilts - some things to see and doArrays of arrays - or 2D arrays. How to program tables.Opportunities for Melksham - new businesses in the townAre there newspapers on New Years Day? Do the shops open on Easter Sunday? Do trains run at Christmas?Perl, Python, PHP, Lua, Linux, and more - and business hotel too. Menu for 2011