SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 1 Day Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 05 Jan 2018 My Price 10.00

copy one array to another array in normal order

I don't understand how to complete these three assignments. Can someone like give me an example of something because i can't figure it out.Here are the problems in the attached section. The below question i can't seem to figure out how to do also. 

Write a program  that will have 4 functions:

-         input an array 

               void inputData( istream &, int [], int);

-         print an array  

               void printData( ostream &, const int [], int);

-         copy one array to another array in normal order

                                                     void copyArray( const int orig[], int dup[], int);
NOTE:        Driver - allocate memory for both arrays.  Supply the data for the 1st array.  Call  the copyArray function 
                        int a[4] = { 7, 14, 9,10};
                        int b[4];
                        copyArray(a,b,4);
                        printData(cout,b,4);


                THE OUTPUT WILL BE:
                     7
                     14
                     9
                     10

The student should NOT create a local array inside the copyArray function.  The reasons is that the local array inside the function

only exists while the function is executing.  After the function returns, all of the local memory is reclaimed.

-         copy one array to another array in reverse order

           void revCopy( const int orig[], int rev[], int);

    Write the main program to test the four functions you wrote

  • #include <iostream>
    using std::cout;
    using std::ios;

    #include <iomanip>
    using std::setw;
    using std::setprecision;
    using std::fixed;
    using std::showpoint;

    #include <cstdlib>
    using std::rand;
    using std::srand;

    #include <ctime>
    using std::time;

    int main()
    {
        const long ROLLS = 36000;
        const int SIZE = 13;

        // array expected contains counts for the expected
        // number of times each sum occurs in 36 rolls of the dice
        /* Write the declaration of array expected here. Assign an
        initializer list containing the expected values here. Use
        SIZE for the number of elements */
        //  expected[0] and expected[1] will have the value of 0
        //     since there are zero ways for two dice to add up to 0 or 1
        //  expected[2] will hold 1,    1 + 1 gives 2
        //  expected[3] will hold 2,    1 + 2 and 2 + 1 both gives 3
        //  expected[4] will hold 3,    1 + 3 and 3 + 1 and 2 + 2 all gives 4




        int x; // first die
        int y; // second die

               /* Write declaration for array sum here. Initialize all
               elements to zero. Use SIZE for the number of elements */
       
       

               //  see page 383 of the text for initializing arrays at compile time

        srand(time(0));

       
        // roll dice 36,000 times
        /* Write a for loop that iterates ROLLS times. Randomly
        generate values for x (i.e., die1) and y (i,e, die2)
        and increment the appropriate counter in array sum that
        corresponds to the sum of x and y */

        cout << setw(10) << "Sum" << setw(10) << "Total" << setw(10)
            << "Expected" << setw(10) << "Actual\n" << fixed << showpoint;

        // display results of rolling dice
        for (int j = 2; j < SIZE; j++)
            cout << setw(10) << j << setw(10) << sum[j]
            << setprecision(3) << setw(9)
            << 100.0 * expected[j] / 36 << "%" << setprecision(3)
            << setw(9) << 100.0 * sum[j] / 36000 << "%\n";

        return 0; // indicates successful completion
    } // end main//   Complete the following program
    //           The program generates 500 numbers between 1 and 6 and stores
    //                them in an array
    //           The program loops and counts how many times each number occurs

    #include <iostream>
    #include <cmath>
    using namespace::std;

    void generateData(int[], int count);

    int countValue(const int[], int howMany, int value);

    void main()
    {
        int data[1000];

        generateData();     //   call the function to generate 500 numbers
                            // between 1 and 6
                            //   store the values in the data array

        for (int i = 1; i <= 6; i++)
        {
            cout << i << " " << countValue() << endl;  // call the
                                                       //countValue function
        }
    }

    void generateData(int d[], int cnt)
    {
        srand(12345);
        int dice;
        for (int i = 0; i < cnt; i++)
        {
            dice = ;     //  generate a random number between 1 and 6
            d[i] = dice;
        }
    }

    int countValue(const int d[], int howMany, int value)
    {
        int total = 0;
        for (int i = 0; i < howMany; i++)
        {
            if ()         //  adjust the total if number in cell i is
                ;      //     equal to the parameter value
        }
        return total;
    }

Answers

(5)
Status NEW Posted 05 Jan 2018 09:01 AM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)