Today’s word is
When you code you will need to take a certain action at some point. The counter is initialized to a natural number, usually zero, and incremented, usually, by one.
Some computer languages allow the following (in php)
$counter++; //Increment by one
$counter–; //Decrement by one
Also, you could use
$counter = $counter + 1; //Increment by one
$counter = $counter – 1; //Decrement by one
Either coding technique has the same effect. Perhaps you would like to produce a grammatically correct sentence. Let’s assume that you wrote some code where you display a text message containing the number of students absent from school. You would use a counter to count the number of students absent. If the counter’s value is zero, you may want to produce the following message:
Great news! Today ALL students are present!
If the counter’s value is one, you may want to produce the following message:
Sweet! Only one student is absent today!
Also, if mode than one student is absent, you may want to produce the following message:
There are five students absent today.
Using the last example and if you were using php as your coding language, the code sample would look like the following:
print “There were ” . $counter . ” students absent today.”;