1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Alisiya [41]
3 years ago
10

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++
Computers and Technology
1 answer:
Goryan [66]3 years ago
5 0

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
HELP ASAP!!!
stiks02 [169]
Comparison would be most suitable. I hope I could be a help


7 0
4 years ago
Read 2 more answers
Karen is designing a website for her uncle's landscaping business. She wants to ensure that it's engaging and provides a lot of
Rashid [163]

Explanation:

Talk About The Benefits. of your  service over other compines

4 0
3 years ago
How to make a sad face on keyboard using alt?
forsale [732]
Literally just do a colon and parenthesis :(

:( :-(
8 0
4 years ago
Read 2 more answers
What is an assembler?
Flauer [41]

an assembler is a program that converts code written in a high-level language to assembly language that the computer processor can execute.

4 0
3 years ago
Which of the following are the functions of an os?
cricket20 [7]
Manage the computer's resources, such as the central processing unit, memory, disk drives, and printers, (2) establish a user interface, and (3) execute and provide services for applications software.
6 0
3 years ago
Other questions:
  • To use files in a c++ program you must include the ________ header file.
    15·1 answer
  • Data is: a. Information endowed with relevance and purpose b. Set of specific objective facts or observations c. Some informatio
    10·1 answer
  • How to use translate on a website?
    15·1 answer
  • Write and run a Python program that asks the user for a temperature in Celsius and converts and outputs the temperature in Fahre
    10·1 answer
  • Which ipv6 prefix will the typical enterprise network receive from the service provider?
    12·1 answer
  • Which small-group format would be most appropriate for the following situation? A large sporting event is coming to town. Key me
    14·2 answers
  • What is a 96.1791 weighted gpa in a 4.0 scale?
    8·1 answer
  • Most presentation programs allow you to save presentations so they can be viewed online by saving them as ____
    5·2 answers
  • Consider the following method, which is intended to count the number of times the letter "A" appears in the string str.
    13·1 answer
  • A manager suspects that one of his team members has been fraudulently accessing confidential and sensitive information and breac
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!