Program that incorporates these two functions

Assignment Help C/C++ Programming
Reference no: EM13166647

Write a program using C++ that sets up an int array which has available positions with subscripts 0 through 199. We wish to enter quite a few integers into this array, but want to fill the array starting in the center, according to the rule: if the new integer is negative it should go in the position with subscript 99 (just left of the center), after moving over to the left by one positional the other integers already stored to the left of center. If the new integer is positive it should go in the position with subscript 100 (just right of the center), after moving over to the right by one position all the other integers already stored to the right of center.

We know the array is large enough to absorb all the new numbers fed in.

One way to write the program uses two functions. The first function accepts the array, the new negative integer, and the number of integers already stored to left of center. The function does the shifting over and puts in the new negative integer, so the array gets changed; it also adds 1 to howmanyonleft. The second function accepts the array, the new positive integer, and the number of integers already stored to right of center. The function does the shifting over and puts in the new positive integer, so the array gets changed; it also adds 1 to howmanyonright.

Write the program that incorporates these two functions, as described. You will notice that the two functions have very similar statements, so you are doing some repetitive C++ code.

Then write a second program that uses just one function that efficiently will handle either situation. Make the one function as concise and elegant as possible. It should not have repetitive code.

Have your program read the data in from a file. Sample data files of various lengths. The program has to read the data from a text file called "InsertNos1.text" and "InsertNos2.txt"

The information on "InsertNos1.text" is

102     34       34       -85      86       -28      -51      -105    71       69       85       -72      -50      -39      12       56       6          4          -23      -79      116            -32      -55      -66      104     104     47       -19      112     -75      -80      -10      117     -108    31       -48      104     -81      -47      -71      49            117     -50      -109    65       37       -55      89       41       14       -110    109

The information on "InsertNos2.text" is

79       66       57       26       -23      50       99       5          -67      -97      -55      -56      -11      -104    -16      58       -82      43       -107    -95      119            -118    117     -31      91       113     -118    9          71       23       -71      -27      -113    98       28       -29      12       -110    -6        -32      -38            66       -119    -120    -93      6          14       93       6          26       33       -94

The ouput is to print out the array at the end of the program, and print out the value of howmanyonleft and the value of howmanyonright.

Reference no: EM13166647

Questions Cloud

Compute the february conversion costs : Compute the February conversion costs in the Filtration Department and the Filtration Department completely processed 150,000 liters in February.
Linked list class to hold a series of integers : 1) Design your own linked list class to hold a series of integers. The class should have member functions for appending, inserting, and deleting nodes. Dont forget to add a destructor that destroys the list. Demonstrate the class with a driver progra..
Be sure to show all declarations : Write a function call that invokes function a. Be sure to show all declarations. However a complete main is not required.
Describe reasons the paper physical properties : Describe reasons the paper's physical properties are different from the water's physical properties.
Program that incorporates these two functions : Write the program that incorporates these two functions, as described. You will notice that the two functions have very similar statements, so you are doing some repetitive C++ code.
Determine the possibility of the use of anabolic steroids : In the Olympics and other major athletic competitions, a GC-MS is used to screen athletes for their use of banned substances such as steroids.
State what would the product of the reaction : what would the product of the reaction between 1,3-dimethoxybenzene and tert-butanol in the presence
Examine the role of the accc is this issue : Examine the role of the ACCC is this issue and whether is appropriate for them to adopt the role they have in this debate. Justify your position.
Publishing and marketing plan a website : Without a publishing and marketing plan a website does not help the client to generate business. Your task in this part of the project is to think of a publishing and marketing plan for your website

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Prepare an arbitrary sinusoidal waveform

Create a program to compute the derivative of an arbitrary input function, with arbitrary duration and arbitrary limits

  The two-dimensional array

1. Given the two-dimensional array declared by the following statement int myArray[4][3] = {{2,4,6},{1,8,10},{3,5,7},[9,11,13}}; what is the value of myArray[1][2]

  Afunction that raises an integer to a positive integer

Write a function that raises an integer to a positive integer power. Call the function x_to_the_n, taking two integer arguments x and n.

  Draw a two-dimensional house seen from the front

Draw a two-dimensional house seen from the front, the way a child would: with a dor, two windows, and a roof with a chimney

  Asks the user for the name of an input file and translates

Write a C++ program that asks the user for the name of an input file and translates the contents of that input file using ROT13. Your  main  function should be responsible for reading the input file and coordinating calls to a value-returning functio..

  Program to generate 100,000 prime numbers

Write a POSIX C/C++ program to generate 100,000 prime numbers. Assume that the program will be run on a computer with 5 CPUs and that your goal is to have this program finish as quickly as possible.

  Cashregister class that can be used with the retailitem clas

Write a CashRegister class that can be used with the RetailItem class that you wrote in Part 1. The CashRegister class should simulate the sale of a retail item. It should have a constructor that accepts a RetailItem object as an argument.

  The manager of a football stadium

The manager of a football stadium wants you to write a program that calculates the total ticket sales after each game. There are four types of tickets-box, sideline, premium and general admission. The data is stored in a file, tickets.txt, in the fol..

  Wave steepness is the ratio of wave height

Wave steepness is the ratio of wave height (WH) to wave length(WL) and is an indicator of wave stability. When wave steepness exceeds a 1/7 ratio; the wave becomes unstable and begins to break. Assume a data file exits with the following header

  A c++ program using the concept of function overloading

write a c++ program using the concept of function overloading for the following options : select the options from [1-3], 1- Area of rectangle 2- Area of square 3- Exit ,

  Program to output value of tenth component of array

Write a C++ statements to perform the following: Set value of fourth component of array alpha to three times  value of eight component minus 57.

  Implementation of data member counter of type int

Write the implementation (.cpp file) of Counter class. Here is the full specification of the class: A data member counter of type int.

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