Write a function print_array()

Assignment Help Basic Computer Science
Reference no: EM13306129

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.

Reference no: EM13306129

Questions Cloud

What intensity of light emerges : The unpolarized light of intensity I(not) is passed through two polarizers with axes oriented at 30degrees from each other. What intensity of light emerges
Find the absolute pressure in the bulb : A meat baster consists of a squeeze bulb attached to a plastic tube. When the bulb is squeezed and released, find the absolute pressure PB in the bulb
Describe binary tree traversals : Describe binary tree traversals (inorder, postorder, preorder and level-order). Give examples of applications of these traversals.
Determine the total force the man must exert on bar ab : A man having a weight of 167lbattempts to hold himself using one of the two methods. Determine the total force he must exert on bar AB in each case and the normal reaction he exerts on the platform at C.
Write a function print_array() : 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..
Prepare an outline marketing audit : Prepare an outline Marketing Audit and set Marketing Objectives for a service offering
Determine whether municipal wastewater containing waste : Determine whether municipal wastewater containing 5 mg/L of selenium is a RCRA hazardous waste
Find maximum tensile stress and maximum compressive stress : The rotor shafte of a helicopter drives the rotor blades that provide the lifting force and is subjected to a combination of torsion and axial loading. it is known that normal stress is 68 MPa and shear stress is -100 MPa.
Frederick w. smith-fedex case : Read the Frederick W. Smith-FedEx Case (Pg 311) - Leadership

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Examine work-related project using systems analysis

Create 4-6-page paper which examines work-related project which used systems analysis for selected business system at department or division level.

  File format would you choose

What file format would you choose for the following tasks: 1. A cartoon strip 2. A 3D model for use on a multimedia presentation on the web

  In html write code for input one number in a input box

in HTML I need the user to input one number in a input box, and another in another input box. Press a button, and have it display in another box.

  Write a program that requests a state and category

Table 4.7 State Flower Nickname Motto California Golden Poppy Golden State Eureka Indiana Peony Hoosier State Crossroads of America Mississippi Magnolia Magnolia State By valor and arms New York Rose Empire State Ever upward Table 4.7 contains in..

  Explaining smartphones as important digital devices

Many resources will suggest that in the next few coming years, smartphones will become the one of the most important digital devices we own. Explain the implications of this statement.

  Which of the following can increase reliability

Which of the following can increase reliability considerably in an Ethernet LAN

  How many outcomes have at least one 1

In this version, there are C(6+3-1,3) = 56 different outcomes in Chuck-a-Luck. Order doesn't matter, just the number's that come up. Out of those 56, how many outcomes have at least one 1?

  Standardize programming between many processor platforms

Do you think the java virtual machine is a good way to standardize programming between many processor platforms? Explain your view with details.

  How an object would be instantiated using both types

explain what constructors do and when they are executed. Explain the two types of constructors. Provide an example class that includes both types of constructor functions and demonstrate how an object would be instantiated using both types of cons..

  Write a java program that creates an array of integers

It should also keep track of a value that appears most often, display what that value was, and how often that value appeared in the array. You may simplify by filling myArray with values such that only one value appears most often.

  Discuss the points and tabulate the strengths and weakness

Please discuss the points and tabulate the strengths and weaknesses

  Explain hacktivism includes cracking for higher purpose

And "hacktivism" includes cracking for "higher purpose". Is it feasible to crack systems and still be ethical? Support the position.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd