Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Write a program in a new file called split.cpp which reads a list of numbers into an array, splits the list into a list of negative numbers and a list of non-negative numbers, each in their separate arrays, and then outputs the arrays of negative and non-negative numbers. A negative integer is one that is strictly less than 0. All other integers are non-negative integers. The program should use the command new to allocate arrays of exactly the correct size.

The program should have a function count() for counting the number of negative elements and the number of non-negative elements of an array, a function split() for splitting the list into negative and non-negative lists, and a function print_array() for printing an array of numbers.

Run split_solution.exe to see an example of the program.

  1. All functions should be written AFTER the main procedure.

  2. A function prototype should be written for each function and placed BEFORE the main

    procedure.

  3. Each function should have a comment explaining what it does.

  4. Each function parameter should have a comment explaining the parameter.

  5. Prompt for the number of elements of the list.

  6. Allocate an array whose size equals the number of elements specified by the user.

  7. Read into the array the elements of the list.

  8. Write a function count() which counts the number of negative elements and the number of non-negative elements of an array. The function should take four parameters, the array, the number of elements in the array, the number of negative elements and the number of non- negative elements.

    The function sets the number of negative and non-negative elements but does not return any value.

  9. In the main program, call the function count() to get the number of negative elements and the number of non-negative elements of the array.

  10. Allocate an array whose size equals the number of negative elements.

  11. Allocate an array whose size equals the number of non-negative elements.

  12. Write a function split() which takes as input 3 arrays, A, B, and C, and stores the negative elements ofA in B and the non-negative elements of A in C. (Use better array names than A, B, and C). The size of array B should be exactly the number of negative elements in array A. The size of array C should be exactly the number of non-negative elements in A.

    As you copy elements from A to B or C, count the number of elements copied to each array. When the function completes, check that the number copied equals exactly the array size. If it does not, print an error message and exit.

    The function should take six parameters, array A, the size of array A, array B, the size of array B, arrayC, and the size of array C.

    The function modifies arrays B and C but does not return any value.

  13. Write a function print_array() which prints the elements of an array. The function should take two parameters, the array and the array length. The function does not modify or return any values.

  14. 14. In the main program, call the function split(), passing the input array and the arrays whose sizes equal the number of even and odd elements.

  15. In the main program, print the phrase "Negative elements: ". Print the array of negative elements using the function print_array().

  16. In the main program, print the phrase "Non-negative elements: ". Print the array of negative elements using the function print_array().

  17. Free the three dynamically allocated arrays. (Points will be deducted if you do not free the arrays).

  18. Be sure to add the header comments "File", "Created by", "Creation Date" and "Synopsis" at the top of the file. Each synopsis should contain a brief description of what the program does.

  19. Be sure that there is a comment documenting each variable.

  20. Be sure that your if statements, for and while loops and blocks are properly indented;

  21. Check your output against the output from the solution executables provided.

22. Note: This lab requires you to dynamically allocate arrays of appropriate size. A large number of points will be deducted if you do not use dynamically allocated arrays, or do not allocate arrays of the correct size.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9885450

Have any Question?


Related Questions in Computer Engineering

Question read the following topic then explain where a

Question: Read the following topic then explain Where a datagram can be fragmented? Where the fragmented datagram can be reassembled? Fragmentation of Datagram Packets used by the IP are called datagrams. For a networks ...

Questions1 suppose you have single connected linkedlist try

Questions: 1. Suppose you have single connected linkedlist. Try to print the list from tail to head using recursive thinking. 2. Explain what is the max heap data structure? 3. Suppose I have a linkedlist data structure. ...

You have requested to develop a program that will record

You have requested to develop a program that will record and process the rainfall totals of a 12 month period. You would use an array to store each month's total. Once all 12 months amounts are entered then your solution ...

A software engineering question regarding black-box testing

A Software Engineering question, regarding Black-Box Testing Techniques: Q:- A program computes its output variable T according to the following formula: [ x as in multiply] 1)T = X x 0.2 + Y x 0.4 + Z x 0.4 where X>= 50 ...

Systems analysis project personal trainer inc owns and

Systems analysis project Personal Trainer, Inc. owns and operates fitness centers in a dozen Midwestern cities. The centers have done well, and the company is planning an international expansion by opening a new "superce ...

A real estate office manages 50 apartment units when the

A real estate office manages 50 apartment units. When the rent is $550 per month, all units are occupied. However, for each $55 increase in rent per month, one unit becomes vacant. How many units should be rented to maxi ...

In python why would one use a decision statement contained

In Python, Why would one use a decision statement contained inside the branch of another decision statement?

Question standards and advantages and disadvantages of

Question: Standards and Advantages and Disadvantages of Standards" Please respond to the following: • From the e-Activity and the information provided by the IEEE 802.11 WLAN Working Group for Wireless Standards, assess ...

What is marketing discipline what is most peoples

What is marketing discipline? What is most people's perception of marketing discipline? Name an organization that has done a great job marketing. What did they do to make you feel this way?

Question what is the smallest accurate big-oh notation for

Question : What is the smallest accurate big-Oh notation for finding an optimal tour for a travelling sales person problem on a graph with with V vertices (nodes) and E edges (arcs) ? (a) O(1) (b) O(V) (c) O(V log V) (d) ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As