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.
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;
}
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.