Skip to main content\(
\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 1.22 Assessment: Pre/Post Operators
Subsection 1.22.1 Subgoals for evaluating an assignment statement
Determine resultant data type of expression
Update variable for pre-increment or pre-decrement operators (side effect)
Evaluate arithmetic expression according to operator precedence
If an assignment statement (=), is Left Hand Side (LHS) a variable? Check data type of value against data type of variable.
Update variable for post-increment or post-decrement operators (side effect)
Exercises 1.22.2 Exercises
1.
2.
3.
4.
Q4: Given the following, what value is stored in variable detla?
int a = 0, b = 1, c = 2, d = 3, delta;
delta = (d / c)++ - (a % ++b);
1.5
2.5
1
2
Compiler error - will not compile
5.
Q5: Which of the following are syntactically valid ways to increment the value of eta
by one? Select all that apply.
eta++;
eta + 1;
++eta;
++eta--;
eta = eta + 1;
You have attempted
of
activities on this page.