Programming

Tips and tricks for programming

Two young Moose - 2010 Algonquin Park

Cout vs Printf

Is the Dinosaur Still King? I have used and abused the printf function since the 80’s.  Yes, the NINETEEN 80’s.  My first C compiler was Power C on a Commodore C64.  By the time I picked up C, I had learned BASIC and Assembly Language (a mnemonic machine language).  You can imagine the smile on …

Cout vs Printf Read More »

keyboard, computer, keys

C++ While and Do While

The Do/While Definition The C++ Do/Do-While loops are 1st class tools to iterate through Arrays, Process Input, output from a database query and much more. Their definitions look like this: do Statement; while(condition); do{ Statement; } while(condition); while(Condition) Statement; while(Condition) { Statement; }; The DO loop will always execute the loop at least once.  It …

C++ While and Do While Read More »

pay, digits, number

C++ For Loop

The For Loop Definition The FOR loop in C and C++ is very powerful and in some ways, outclasses the FOR loop in other languages.  Its basic definition looks like this: for(Initializer; Test; Incrementor) { foo(); foowho(); }; Or for(Initializer; Test; Incrementor) foo(); // Loopy stuff done here Lets look at an example of counting …

C++ For Loop Read More »