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
A plan to budget time for studying and activities is referred to as
krok68 [10]

Answer:

a study schedule.

Explanation:

A plan to budget time for studying and activities is referred to as a study schedule. A study schedule is mostly designed by a student and it comprises of their learning goals and objectives, as well as allocated time to start and  complete.

The main purpose of a study schedule is to avail students the opportunity to maximize their time and improve their ability to study by themselves through an organized schedule for specific subjects, courses or class.

3 0
2 years ago
The ........ tag is used to create a link to another document​
Free_Kalibri [48]

Answer:

The "a" tag or <a></a> and its "h<u>r</u>ef" attribute <a href="#"></a>

Explanation:

In html there is only one way to create a link to an external source or a bookmark. The tag is created using the element <a>.

The attribute "href" is then added to describe the link of where it is to point to.

Example:

<a href="google.com">Go to Google</a>

While the text in between the tag describes what the link is about.

7 0
2 years ago
Putting commands in correct order so computers can read the commands
lana66690 [7]

Answer:

its b I think I'm pretty sure

8 0
2 years ago
PLEASE HELP ANSWER THIS only if you know BOTH ANSWERS!
Leya [2.2K]

Answer:

For the first question I think it is chains

The second question.

The woman is suspicious at hotel doors have numbers so how could he have been confused

Explanation:

8 0
3 years ago
Read 2 more answers
How do you use bold text?
taurus [48]

Answer:

Android: Tap and hold the text you're entering in the text field, then choose Bold, Italic, or More . Tap More to choose Strikethrough or Monospace. iPhone: Tap the text you're entering in the text field > Select or Select All > B_I_U. Then, choose Bold, Italic, Strikethrough, or Monospace.

Explanation:

8 0
2 years ago
Read 2 more answers
Other questions:
  • _____ is an information-analysis tool that involves the automated discovery of patterns and relationships in a data warehouse.
    12·1 answer
  • How Java provides protection through stack inspection approach ?
    7·1 answer
  • Need help answering this
    7·1 answer
  • technology might not possess emotional intelligence but it can certainly influence ours. how have technological changes affected
    7·1 answer
  • Organizing speech ideas according to physical space, direction, or location calls for a _____ organizational pattern.
    11·1 answer
  • What is the definition of trouble shooting.
    12·1 answer
  • The director of security at an organization has begun reviewing vulnerability scanner results and notices a wide range of vulner
    11·1 answer
  • Who is your favorite person from squid game?
    13·2 answers
  • Como interactua el hardware de la computadora con el ser humano
    15·1 answer
  • A(n) ____ is a web-based repository of information that anyone can access, contribute to, or modify.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!