Skip to main content
Contents Index
Dark Mode 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 9.10 The Idea of a Flag
Despite the fact that the C-programming language does not have a boolean data type, we can simulate boolean (true/false) behavior using an integer-type variable. This is often called a flag.
Investigate 9.8 .
What are some scenarios where it would be useful to have a true/false variable? Any past activities come to mind?
Check Your Understanding Check Your Understanding
1.
What is the value of the variable d once the following code has been executed:
int d, num;
num = 17;
d = ((17%3)==0);