c++
page 1 page 2
page 3 page 4 page 5 page 6 page 7 page 8
now you know how to make a variable, talk about it, ask for it, and talk about it some more.
believe it or not, this will be useful eventually. let's revisit variables, so you don't walk
out of here uneducated.
when making a variable, you have the choice to initialize it at that moment or not. simply
saying
code:
int number;
is only declaring it (pay attention), giving you a blank integer (most compilers
assume 0) and nothing more. if you want to print this, chances are it'll tell you 0.
sometimes you'll want to set the value immediately, in which case you'd do a two hit
combo: declaring and initializing.
code:
int number = 5;
that'd give you an integer named number, whose value is 5.
i think that's more than enough integers, let's talk about more variable (and later, function)
types. here are the ones you'll find the most helpful to know about:
char: one character (a letter, perhaps), or in some cases a small integer. 1 byte
int: integer, which we've discussed. aka counting numbers. 4 bytes
bool: boolean, two possible values - true and false. 1 byte
float: floating point number, can include decimals. 7 digits. 4 bytes
double: double precision floating point, also takes decimals. 15 digits. 8 bytes
the amount of bytes is hardly necessary to know these days, since computers are much more
advanced, fast, and spacious than they were years ago. but, the more you know. as i've hinted
at before, all the types can be used to declare functions, as well as variables. that will be on
the next page, this one would be horribly long otherwise.
page 1 page 2
page 3 page 4 page 5 page 6 page 7 page 8