CHALLENGE 3.17.2: Conditional assignment. ACTIVITY Using a conditional expression, write a statement that increments numUsers if updateDirection is 1, otherwise decrements numUsers. Ex: if numUsers is 8 and updateDirection is 1, numUsers becomes 9; if updateDirection is 0, numUsers becomes 7. Hint: Start with "numUsers = ..". 1 #include 2 using namespace std; 1 test 3 passed 4 int main) { int numUsers; int updateDirection; 6 All tests 7 passed cin >> numUsers; cin updateDirection; 10 /* Your solution goes here */ 11 12 numUsers << endl; cout <<"New value is: 13 14 return 0; 15 16 Run

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter3: Input/output
Section: Chapter Questions
Problem 12SA: 12. What is the output of the following program? (2, 3, 6, 8) #include <iostream> #include...
icon
Related questions
Question
CHALLENGE
3.17.2: Conditional assignment.
ACTIVITY
Using a conditional expression, write a statement that increments numUsers if updateDirection is 1, otherwise decrements
numUsers. Ex: if numUsers is 8 and updateDirection is 1, numUsers becomes 9; if updateDirection is 0, numUsers becomes 7.
Hint: Start with "numUsers = ..".
1 #include <iostream>
2 using namespace std;
1 test
3
passed
4 int main) {
int numUsers;
int updateDirection;
6
All tests
7
passed
cin >> numUsers;
cin updateDirection;
10
/* Your solution goes here */
11
12
numUsers << endl;
cout <<"New value is:
13
14
return 0;
15
16
Run
Transcribed Image Text:CHALLENGE 3.17.2: Conditional assignment. ACTIVITY Using a conditional expression, write a statement that increments numUsers if updateDirection is 1, otherwise decrements numUsers. Ex: if numUsers is 8 and updateDirection is 1, numUsers becomes 9; if updateDirection is 0, numUsers becomes 7. Hint: Start with "numUsers = ..". 1 #include <iostream> 2 using namespace std; 1 test 3 passed 4 int main) { int numUsers; int updateDirection; 6 All tests 7 passed cin >> numUsers; cin updateDirection; 10 /* Your solution goes here */ 11 12 numUsers << endl; cout <<"New value is: 13 14 return 0; 15 16 Run
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning