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
What sequence is used to create a brochure document from a template?
GenaCL600 [577]

Answer:

computer is used to create a voucher document

6 0
3 years ago
Read 2 more answers
Write a c++ program that accepts a string from the user and then replaces all occurrences of the letter e with the letter x
mixer [17]

Answer:

#include <iostream>

using namespace std;

int main()

{

   string str;

   cout<<"Enter the string: ";

   cin>>str;

   for(int i=0;str[i]!='\0';i++){

       if(str[i]=='e'){

           str[i]='x';

       }

   }

   cout<<"the string is: "<<str<<endl;

  return 0;

}

Explanation:

First, include the library iostream for using the input/output instructions.

Create the main function and declare the variables.

Then, use the cout instruction and print the message on the screen.

cin store the string enter by the user into a variable.

After that, take a for loop and if-else statement for checking the condition if the string contains the 'e', then change that alphabet to 'x'.

This process continues until the string not empty.

Finally, print the updated string.

6 0
3 years ago
Which of the following statements is true? Methods and instance variables can both be either public or private. Information hidi
Alex777 [14]

Answer:

B

Explanation:

8 0
3 years ago
A vector is based on...​
Vaselesa [24]

Answer:

Magnitude and direction

Explanation:

Vector quantity is a quantity which is described by magnitude and direction

8 0
3 years ago
Suggest me a website or any channel for learning coding.
gulaghasi [49]

Answer: Codeacademy. One of the most popular free places to learn coding is Codeacademy.

Explanation:

6 0
3 years ago
Other questions:
  • Which markup language would be considered the most current for web design? HTLM, HTML5, XHTLM, XHTML 6
    14·2 answers
  • What is the purpose of lookup tables in spreadsheet software
    13·2 answers
  • What is a basic operation of computers
    13·1 answer
  • In your own words, describe what Internet Protocols are. Why is it important to have agreed upon protocols?
    6·1 answer
  • Visual-verbal synergy has nothing to do with text, but solely with images used in a design.
    9·1 answer
  • What soft ware can you use to erase all of your data from a hard drive safely
    13·1 answer
  • What is the build in libary function to compare two strings?​
    15·1 answer
  • Several disaster relief nonprofits want to create a centralized application and repository of information so that they can effic
    7·1 answer
  • Which interpersonal skill is the most important for a telecom technician to develop?
    7·1 answer
  • Please help me plss! PLS​
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!