Skip to main content
Contents
Dark Mode Prev Up Next Scratch ActiveCode Profile
\(
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section 2.6 Summary & Reading Questions
All variables must be declared before use in C++.
C++ has typical built-in numeric types:
int
is for integers and
float
and
double
are used for floating point depending on the number of digits desired.
C++ has the Boolean type
bool
that holds
true
or
false
.
The character data type
char
holds a single character which is encased in single quotes.
Pointers are a type of variable that stores a memory address. To declare a pointer, an
*
is used before the variable name that is supposed to store the location.
Reading Questions Reading Questions
1.
If I want to use the
char
type in C++, what set of symbols must be used?
Good job!
No, double quotes are only used for string.
β β or " " may be used
No. Only one set of symbols may be used.
It depends upon the implementation.
No. The implementation is consistent.
One of the above is indeed correct.
2.
3.
How may one reference a variableβs memory address in C++?
Right! ``&`` is the "address-of" operator, used to reference an address.
No. ``int *p;`` defines a pointer to an integer, and ``*p`` would dereference that pointer, i.e. retrieve the data that p points to.
No. This is used in Python.
It depends upon the implementation.
No. Try again.
One of the above is indeed correct.
4.
You have attempted
of
activities on this page.