CHALLENGE 3.17.1: Conditional expression: Print negative or positive. ACTIVITY Create a conditional expression that evaluates to string "negative" if userVal is less than 0, and "non-negative" otherwise. Ex: If userVal is -9, output is: -9 is negative 1 #include 2 #include 1 test 3 using namespace std; passed 4 5 int main ) { string condStr; int userVal; 6 All tests 7 passed 8 cin userVal; 9 10 /* Your solution goes here */; condStr 11 12

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.1: Conditional expression: Print negative or positive.
ACTIVITY
Create a conditional expression that evaluates to string "negative" if userVal is less than 0, and "non-negative" otherwise. Ex: If
userVal is -9, output is:
-9 is negative
1 #include <iostream>
2 #include <string>
1 test
3 using namespace std;
passed
4
5 int main ) {
string condStr;
int userVal;
6
All tests
7
passed
8
cin userVal;
9
10
/* Your solution goes here */;
condStr
11
12
<condStr << "." « endl;
cout << userVal << " is '
13
14
return 0;
15
16
Run
DD
Transcribed Image Text:CHALLENGE 3.17.1: Conditional expression: Print negative or positive. ACTIVITY Create a conditional expression that evaluates to string "negative" if userVal is less than 0, and "non-negative" otherwise. Ex: If userVal is -9, output is: -9 is negative 1 #include <iostream> 2 #include <string> 1 test 3 using namespace std; passed 4 5 int main ) { string condStr; int userVal; 6 All tests 7 passed 8 cin userVal; 9 10 /* Your solution goes here */; condStr 11 12 <condStr << "." « endl; cout << userVal << " is ' 13 14 return 0; 15 16 Run DD
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

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