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
Kelvin owns a small trading firm. Recently, he suspected that some of his employees were using fraudulent activities for their p
RideAnS [48]

Answer:

D. spyware

Explanation:

Well it kind of explains itself. He wants to "spy" on their activities.

7 0
3 years ago
Read 2 more answers
. When attempting to minimize memory usage, the most efficient way to do group processing when using the MEANS procedure is to u
MrRissso [65]

Answer:

A. the BY statement.

Explanation:

The BY statement aids the procedure MEANS to develop the tree for the current BY group only, thereby analyze the stats, and clean the tree prior to the start and development of the next BY group.

However, without the BY statement, procedure MEANS develops its AVL tree for both the whole file and all sector estimates crossings established in CLASS.

Hence, in this case, the correct answer is the BY Statement.

8 0
3 years ago
Which of the following does not make a good analysis class? (Points : 6) its name reflects its intent
satela [25.4K]

Answer:it has high coupling

Explanation: Coupling is the property in the field of computer program that is defined as the functions ,data and  codes of the program are dependent on each other and cannot be changed independently if requires. Thus,high amount of coupling is not considered as good factor due to high interdependence. Loose coupling can be still permitted.

Other options are correct because name of the class should reflect the purpose and well defined responsibilities should be present, modeling of certain component and high cohesion means keeping similar functions togather is also required. So, the only bad factor is high coupling

6 0
2 years ago
Which of the following operating systems would allow a user to add functionality and sell or give away their versions?
olchik [2.2K]

Answer:open source

Explanation: what is's called

4 0
2 years ago
In his article, “How to Publish Without Perishing,” what does James Gleick believe most people do when they really read a book?
jonny [76]

Answer:

James Gleick believes that they immerse themselves in a rich textual world. The answer is C.

3 0
2 years ago
Read 2 more answers
Other questions:
  • Raeball was a lovin doll. And she spoke her mind as she stood tall. She made you special and loved. You're missed by so many. An
    10·2 answers
  • Dr. Laos gets a referral for a 6 month old who has become listless and stopped eating lately. Her pediatrician wanted her to be
    15·1 answer
  • Name some technologies that engineers create
    13·1 answer
  • Which of the following is a malicious program that can replicate and spread from computer to computer?
    13·2 answers
  • Which statement most aptly defines the term networking?
    8·1 answer
  • Explain in three to four sentences what happens to data packets once they leave a node.
    11·2 answers
  • Which of the following statements about electronic cover letters is true?
    14·2 answers
  • MICR is an input or output devices
    5·1 answer
  • Write a function definition for a function which takes one parameter and returns twice that parameter
    12·1 answer
  • What is the FaFASA4caster used for
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!