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

  Create the appropriate constructor, getters and setters

Create the appropriate constructor, getters and setters for the class. Create an instance of Student for each of the students listed above from array. Construct the instance with lastname, firstname, and job.

  Distinguish syntax and purpose of while-loop and for-loop

Distinguish the syntax and purpose of while-loop and syntax of a for-loop. Give C++ code examples of both loops and descriibe the main differences.

  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

  Write function that finds the minimum of three double value

1. Write a function that finds the minimum of three double values. This function should use another function that finds the minimum of two double values.

  Program to compute and show miles per gallon

Create the program in C++ which will input miles driven and gallons used (both as integers) for each tankful. Program must compute and show miles per gallon.

  Takes 100 number in an array

Write a program in c++ that takes 100 number in an array and add them and print the sum

  Dynamic character arrays

Dynamic character arrays str and add contain strings. Write a function append that uses str and add as arguments and appends add to the end of str. Write a main program that illustrates the use of function append to concatenate five strings.

  Write a program that contains a main function

Write a program that contains a main function and three other functions that will return various attribute information about an array of floating point

  Write a full program that implements the aggregation concept

Write a full program that implements the aggregation concept for the Mail Message, Header , Body and Attachment classes.

  Write a program that accepts as input, without prompts

Write a program that accepts as input, without prompts, a series of short values, terminated by end of file. The program outputs one line:

  Describe an example of a base

Describe an example of a base and a derived class that shows base-class functions that are overridden in the derived class. Provide the syntax, showing the class definitions of both classes.

  The stack-based routing scheme

the stack-based routing scheme you are to have a stack of maze locations.

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