Introduction

Arrays are a fundamental concept in C++. Utilizing the supplied template, develop the specified functions to perform array operations. Further requirements are spelled out in the comment section of the template so read carefully.

  • Random Seeding
  • Array Initialization
  • Linear Search
  • Bubble Sort
  • Summation
  • Determining largest, smallest, and average

Submission Format

  • You should place your code in one (1) file named ArrayOperations.cpp
  • Zip up the file and title the zip with the following format: FSUID, underscore, assign4 (e.g. John F. Doe might be JFD13_assign4.zip)
  • Submit the zip file.

Template

A template file named ArrayOperations.cpp is provided on the BlackBoard website. It is populated with these empty functions. Your job is to fill these functions with the necessary functionality.

// [File name]
// [Your name]
// [Date]
// [Version]
// [Description]
// DO NOT REMOVE ANY OF THE FOLLOWING CODE THAT
// IS GIVEN TO YOU IN THIS TEMPLATE (including comments)
#include
// Function Prototypes
// DO NOT REMOVE THIS LINE OR THE NEXT
//[BEGIN MAIN]
int main()
{
// This entire main() function will be deleted
// during the assessment and replaced with
// another main() function that tests your code.
// This size may change!
// Make sure your functions work for any array size.
const int ARRAY_SIZE = 20;
int a[ARRAY_SIZE];
// Develop code here to test your functions
// You may use std::cout in any tests you develop
// DO NOT put std::cout statements in any of the
// provided function skeletons.
// DO NOT WRITE CODE ABOVE HERE
// ================================
// ================================
// DO NOT WRITE CODE BELOW HERE
std::cout << "Press ENTER";
std::cin.get();
return 0;
}
// DO NOT REMOVE THIS LINE OR THE NEXT
//[END MAIN]
// Implement all of the following functions
// DO NOT put any std::cout statements in them.
// DO NOT change their signatures
// Implement the required functionality only
// Do all of your coding between these two sections
// in each function:
// ================================
// [Your code here]
// ================================
// Failure to follow these simple rules will result
// in major deductions.
void SeedRand(int x)
{
// Seed the random number generator with x
// ================================
// ================================
}
void InitializeArray(int a[], int arraySize)
{
// Develop an algorithm that inserts random numbers
// between 1 and 100 into a[]
// ================================
// ================================
}
bool Contains(int a[], int arraySize, int testVal)
{
bool contains = false;
// Develop a linear search algorithm that tests
// whether the array contains testVal
// ================================
// ================================
return contains;
}
void BubbleSort(int a[], int arraySize)
{
// Develop an algorithm that performs the bubble sort
// ================================
// ================================
}
int SumArray(int a[], int arraySize)
{
int sum = 0;
// Develop an algorithm that sums the entire array
// and RETURNS the result
// ================================
// ================================
return sum;
}
int Largest(int a[], int arraySize)
{
int largest = a[0];
// Develop an algorithm to figure out the largest value
// ================================
// ================================
return largest;
}
int Smallest(int a[], int arraySize)
{
int smallest = a[0];
// Develop an algorithm to figure out the smallest value
// ================================
// ================================
return smallest;
}
double Average(int a[], int arraySize)
{
double average = 0;
// Develop an algorithm to figure out the average INCLUDING decimals
// You might find your previous SumArray function useful
// ================================
// ================================
return average;
}

Sample Output

This sample output is an example only. The code you are required to write does not need to contain ANY std::cout statements. These statements will be inserted by the assessment tool to test your functions. You may, however, use any std::cout statements in the provided main() function to do self-testing. See image.

Notes

  • Use the main() function provided in the template to develop any tests you think are necessary.
  • The main() function that you implement will be deleted in the assessment. A new main() function will be inserted that tests your functions.
  • Do not assume that the assessment tool will utilize an array of size 20. This may change so be sure your code can accommodate that.
  • Your code needs comments! You will be deducted significant points depending on how shy your code is on comments.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.