Answer:
num_users = (update_direction == 3) ? (++num_users) : (--num_users);
Explanation:
A. Using the regular if..else statement, the response to the question would be like so;
if (update_direction == 3) {
++num_users; // this will increment num_users by 1
}
else {
-- num_users; //this will decrement num_users by 1
}
Note: A conditional expression has the following format;
<em>testcondition ? true : false;</em>
where
a. <em>testcondition </em>is the condition to be tested for. In this case, if update_direction is 3 (update_direction == 3).
b. <em>true </em>is the statement to be executed if the <em>testcondition</em> is true.
c. false is the statement to be executed it the <em>testcondition</em> is false.
B. Converting the above code snippet (the if..else statement in A above) into a conditional expression statement we have;
num_users = (update_direction == 3) ? (++num_users) : (--num_users);
<em>Hope this helps!</em>