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]
3 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]3 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
BRAINLIEST You have a small company and want to keep your costs low, but it is important your employees share data. Which networ
solmaris [256]

Answer:Peer-to-peer

Explanation: I hope this helps

5 0
3 years ago
Read 2 more answers
The objective is to write the program that can help you process the database. Your program should be able to (1) display the dat
miskamm [114]

Answer:

;;;;iiiiihhhhhhhhhhhhhhhhhkmbjhv hibv

Explanation:

7 0
4 years ago
Match the vocabulary to the appropriate definition.
Allisa [31]

Answer:

Pulling related code together in objects is Arrays

Helps programmers when they revisit code or are new to code-- Documentation

Explanation:

This is all I know

3 0
2 years ago
Write a SELECT statement that returns these columns from the Orders table: The card_number column The length of the card_number
VashaNatasha [74]

Answer:

Select CardNumber, LEN(cardNumber) as CARDLEN,

Right (CardNumberR,4) AS LAST4DIGITS FROM ORDER

Explanation:

5 0
4 years ago
Which of the following is an example of how cookies are used? To create a stronger password To customize advertisements based on
fiasKO [112]

The one among the options that is an example of how cookies are used to customize advertisements based on your history.

<h3>What do cookies do?</h3>

A cookie is known to be a kind of a small text file that is said to be often saved on your computer if a person do visit any kind of websites.

Note also that  a cookie is often used to get one to often remember settings that they have their last visit to any website.

For example Amazon is known to often cookies to help to know if or when a person revisit the site.

Hence, The one among the options that is an example of how cookies are used to customize advertisements based on your history.

Learn more about cookies from

brainly.com/question/14102192

#SPJ1

8 0
2 years ago
Other questions:
  • When age = 16, what action would the program execute?
    6·1 answer
  • "The OSI model has seven layers and the DoD has four. At which layer does SMTP works in both models"?
    15·1 answer
  • Data mining is defined as: a)Separating data and programs such that each can be changed without changing the other b)Allowing ma
    5·1 answer
  • The process of saving files to disk is called.<br> A.read<br> B. Write<br> C. Lock<br> D. Protect
    6·1 answer
  • On the seventh day of the iteration, the team realizes that they will not complete 5 of the 13 stories. the product owner says s
    12·1 answer
  • Define Technology In Your Own Words.
    8·1 answer
  • Describe the steps to play a presentation the way your audience will see it.
    8·2 answers
  • To summarize means to
    11·2 answers
  • Sean is frustrated with having to use separate editors, compilers, libraries, plug-ins, and debugers. What could Sean use to mak
    8·1 answer
  • Which remote access role service allows publishingweb-based applications for use by clients outside thenetwork?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!