Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Posting this out of desperation ... taking 6 classes 5 on campus one online ...

ID: 3634268 • Letter: P

Question

Posting this out of desperation ... taking 6 classes 5 on campus one online ... comp sci is killing me final is next week and this is a project due tomorrow stress is killing me i would appreciate if any one would help... here is the question.... THANKS ALOT.



Write a C++ program in the following steps:

Step 1. Write a declaration of a named array type, and then declare three arrays of that type. The array type should be called DataSet, and the three arrays should be called original, copy, and diff. Each array should hold five float values.


Step 2. Using the three arrays declared in Step 1, write For loops that initialize original, copy, and diff. Make copy a duplicate of original and diff contain different values.


Step 3. Write a function heading for a function called Equals that takes two arrays of the DataSet type declared in Step 1, and returns a bool result. The array parameters should be const, as they are input-only parameters to the function.


Step 4. Write the body of the Equals function described in Step 3. It should return true if each element of the first array is equal to its corresponding element in the second array.


Step 5. Write the main function that contains the For loops written in Step 2 and makes two calls to the Equals function. In the first call, array original and copy are used as arguments. In the second call, original and diff are used as arguments. Write output statements that print messages articul

ating the results of the two function calls (e.g., “Array original are copy are the same.” or “Array original and diff are different.”).

Explanation / Answer

Dear,

#include <iostream>
using namespace std;

// float is named as DataSet
#define DataSet float
#define size 5

// function prototype
bool Equals(const DataSet d1[], const DataSet d2[]);

// main function
int main()
{
    // 3 arrays
    DataSet original[size], copy[size], diff[size];

    // initializing the above three arrays
    for(int i=0; i<size; i++)
    {
        original[i] = 1.0;
        // making copy of original
        copy[i] = original[i];
        // fills diif array with different values
        diff[i] = (float) i;
    }

    // checking the Equals function with original and copy arrays
    if(Equals(original, copy))
        printf(" Array original and copy are the same");
    else
        printf(" Array original and copy are different");

    // checking the Equals function with original and diff arrays
    if(Equals(original, diff))
        printf(" Array original and diff are the same");
    else
        printf(" Array original and diff are different");

    printf(" ");
    return 0;
}

// returns true if each element of first array isequals to the
// corresponding element in the second array otherwise returns flase
bool Equals(const DataSet d1[], const DataSet d2[])
{
    for(int i=0; i<size; i++)
        if(d1[i] != d2[i])
            return false;
    return true;
}

I hope this would helps you...

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote