Skip to main content
Contents Index
Search Book
Search Results:
No results.
Readability settings Prev Up Next
\(\newcommand{\N}{\mathbb N}
\newcommand{\Z}{\mathbb Z}
\newcommand{\Q}{\mathbb Q}
\newcommand{\R}{\mathbb R}
\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 19.3 Practice: Dereferencing a Pointer
Check Your Understanding Check Your Understanding
1.
You want to write a function that increases the integer value stored in a variable num by one. Given the following function definition, what is the correct function call? Assume that a variable num of type int has been declared and initialized.
void increasebyone(int *a)
{
*a = *a + 1;
}
Feel free to use the window below to try out some code. Be sure to work the correct answer out "by hand" first before verifying your answer using the code window.
admin ..... open in new window
Correct
Not quite. Try again!
Not quite. Try again!
num = increasebyone(&num);
Not quite. Try again!
2.
What does the following piece of code do?
float num = 5.0;
float *pointer;
pointer = #
*pointer = *pointer + 1.0;
printf("%f", *pointer);
This code prints out the number 6.000000 to the default output.
Correct
This code prints out the address of the variable pointer to the default output.
Not quite. Try again!
This code prints out the number 5.000000 to the default output.
Not quite. Try again!
This code prints the address of the variable num to the default output.
Not quite. Try again!