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 22.2 Practice: Linear Search
Check Your Understanding Check Your Understanding
1.
Quick review question: Which of the following is the correct way to declare and initialize a string?
char name[] = "cool_file_name";
Correct
char name[50]; name = "cool_file_name";
Not quite. Try again!
char name = "cool_file_name";
Not quite. Try again!
char = "cool_file_name"[50];
Not quite. Try again!
2.
More review: Is there anything wrong with the following:
char name[10];
. . .
strcpy(name, "TodayIsMonday");
3.
Even more review: What is the result of the following:
strcmp("my_apple", "my_banana");
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
a negative number
Correct
the letter โbโ
Not quite. Try again!
a positive number
Not quite. Try again!
zero
Not quite. Try again!
the letter โaโ
Not quite. Try again!
4.
Final review question (I promise!): Suppose a string has been declared as follows:
char food[30];
You want the user to enter their favorite food and store the response in the string food. What is the correct command to do so?
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!
Not quite. Try again!