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. PLEASE USE C++
1 answer:
Answer:
PROGRAMMING APPROACH:
Define the necessary header file using namespace. Define the main() method. Declare variable inside the function(). Print result.
Explanation:
Required C++ Code:
#include<iostream>
#include<string>
using namespace std;
int main()
{
string condStr;
int userVal;
cin>>userVal;
condStr=(userVal<0)?("negative"):("non-negative");
cout<<userVal<< " is "<< condStr <<"."<<endl;
}
OUTPUT:
-2
-2 is negative.
You might be interested in
Optima battery because it is stronger than a factory battery
Answer:
Open the shape’s properties window, and type the height value multiplied by 2 and the width value multiplied by 3.
Explanation:
The answer to the question you have asked is <u><em>"B" . </em></u> Because if you really think about it, there is no possible way that "Good" can be a keyword of "Hideous".
Answer:
laptop
Explanation:
laptops are small and they can be taken anywhere.