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
Flauer [41]
2 years ago
9

Add Try/Catch error checking To make sure that the user enters valid values in your program. To catch negative values passed to

constructor. To catch if not enough memory is available for list. (Hint: bad_alloc)
Computers and Technology
1 answer:
ryzh [129]2 years ago
4 0

Answer:

int main()

{

 cout<<"Enter the size of array\n";

 int n;

 try{

 cin>>n;//get size of array

 if (n > 0){

 List list;//make object of list class

 try{

     list.init(n);//initialize the list

     list.fillData();//fill the data

     list.print();//print the data

     list.sortData();//sort the  data

     cout<<"\n--- After sorting the data---\n";

     list.print();//print the data

     cout<<"Enter the element to search\n";

     int x;

     cin>>x;//get element to search

     list.searchElement(x);//call the search function

 }

 catch (std::bad_alloc){

   cout<<"Sorry, could not allocate memory for list object.";

 }

 }else{

   throw('Negative Number detected');

 }

 }

 catch (int n){

   cout<<"The number should be a positive integer.";

 }

   return 0;

}

Explanation:

The try and catch keywords come in pairs, as they are used to control exceptions in the C++ source code. The try keyword checks for error in the source code given the condition (if the n integer variable is greater than 0). If the condition is met, the code in the try code block runs otherwise the catch keyword catches the error of a negative number (if the n variable in less than 0).

You might be interested in
After saving her presentation initially, Leah realizes she needs to add another content slide. She adds the slide and is ready t
liberstina [14]

Answer:

a, c, & e

Explanation:

7 0
3 years ago
are you in active recovery from a substance use disorder (addiction)? active recovery is defined as being free from an alcohol o
salantis [7]

No, I am not in active recovery from a substance use disorder (addiction). Active recovery is defined as being free from an alcohol or other drug use disorder or no longer using alcohol or other drugs is a true statement.

<h3>What does it mean to be in addiction recovery?</h3>

The statement  implies that a person is working very hard to be  successful in handling their addiction and getting back control of your life.

Note that it is not an easy road but one can overcome. Therefore, my response is No, I am not in active recovery from a substance use disorder (addiction) because i do not drink it. Active recovery is defined as being free from an alcohol or other drug use disorder or no longer using alcohol or other drugs is a true statement.

Learn more about Active recovery from

brainly.com/question/28027699

#SPJ1

4 0
1 year ago
If you use the assign software to a user option, how does the new software install to the user's computer? 70-411
Serggg [28]
Hi,

If you install a new software and you select option for all users the software will be installed in a special folder that is shared by all the users and each user would represent a subfolder in the shared folder.

Hope this helps.
r3t40
3 0
2 years ago
Nicotine us a dangerous chemical found in Cigarettes; it is accompanied by two other very harmful chemicals. These are
NNADVOKAT [17]

Answer: Carbon Monoxide and Tar.

4 0
2 years ago
Which software-development methodology would be best if an organization needed to develop a software tool for a small group of u
xxTIMURxx [149]
I think prototyping model is best
3 0
3 years ago
Other questions:
  • The Huntington Boys and Girls Club is conducting a fundraiser by selling chili dinners to go. The price is $7 for an adult meal
    8·1 answer
  • to prevent long page load time for pages containing images. It is best to use a compress file formatlike jpeg as well as appropr
    6·2 answers
  • Angle, oblique, regular, demi, roman, heavy, extra bold, expanded, and compressed are ___________ . Select one: A. type styles B
    10·1 answer
  • Does functionality provided by the app play an important role in a decision to
    13·1 answer
  • What do developers do to support software products? explain to users which development process model was used to make the produc
    8·1 answer
  • Georgenotfound??? question mark??
    15·2 answers
  • The Internet acts as a(n) blank services such as The World Wide Web and email
    6·2 answers
  • Which statement describes how to insert the IF, COUNTIF, or SUM function into a cell?
    11·1 answer
  • Name any three areas of of application of excel.
    12·1 answer
  • What is the digital revolution and how did it change society?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!