Here are a few terms I know you've heard before, but may not have latched onto as effectively as you could have. (Lot's of people have trouble remembering these and/or getting them straight/clear!)
We often use vocabulary terms in programming that seem familiar but just not quite 'on'. That's because programming languages (and they are languages) were developed by people who started out as mathematicians and then studied linguistics. So when we talk about programming, we use some mathematics terms and some terms from language studies (like composition/grammar).
Here's a little chart to help you tell what some terms mean when they come up later in the course:
Composition | Mathematics | Programming |
---|---|---|
verb | operator/operation function |
operator/operation function |
noun | numeral | literal [poor usage] constant |
pronoun | variable constant |
variable constant |
adjective | number system set |
data type comment |
adverb | ( ) [as used to change operator evaluation order] | typecast (data_type) [as used to change operator evaluation order] |
phrase | expression | expression |
sentence | equation inequality |
statement |
paragraph | proof theorem |
block function |
table of contents | list of variables/constants extracted from a word problem before solution | prototype function declaration |
appendix foot/endnote |
postulate axiom lemma |
library comment |
paper report composition |
theory algebra |
program |
Many people become confused betwixt/amongst 'variable', 'constant', and 'literal'. Technically, a variable is a representation of a quantity that can vary or change. A constant represents a value that is to not change -- i.e. to remain constant/consistent.
In mathematics, these distinctions are made in a more verbal manner such as:
Given a polynomial such as: 2 a x + b x + c Where a, b, and c are real coefficients and x the independent variable. ...
Or:
Irrational quantities include the square roots of numbers which are not perfect squares as well as ones with special applications of interest such as e or π.
But in programming (most especially C++), the compiler must be made to understand the difference. Hence we have the const keyword to distinguish a declaration for a variable from a declaration for a constant. (A variable may be initialized at declaration time, whereas a constant must be initialized.)
So, then, what's a literal? Well, in mathematics, they would say 'numeral' to distinguish (if needed) a value that is specifically represented from one that is symbolically represented -- but still a simple value and not one of the primary variables of the problem.
Of course, in programming, we have more than just numbers to work with. We have logical values, individual characters, and even sequences of characters. Two common definitions I've liked over the years are that a literal is "a value literally typed into the source code by the programmer" and, perhaps more simply, a literal is "a value that represents itself". The important distinction between a constant and a literal is that a constant has a memory location in which it resides but a literal [technically] does not.
Here are a few samples of literals a programmer might use in her program:
char and 'strings' are typically coded in the binary memory location(s) using ASCII (or one of its immediate descendants). wchar_t and 'wide strings' are typically coded in some form of Unicode (or other related standards).