pseudorandomly generated integer values

Design and implement a c++ program which, when executed by the computer, fills an array with pseudorandomly generated integer values between Min_Value and Max Value, which are constants. The array should hold n values, where n is a constant. The computer should then output the contents of the array and sum of array element values. Write and invoke a function to sum the elements in the array in the main function.

I need some assistance on how to get the Min_value and Max_value to work for my Programming assignment. If its possible give me feedback if I followed the intructions correctly.

//

#include "stdafx.h"
#include <iostream>

using namespace std;

void Fill(int[]);
void SumArray(int[], int&);
int GetMaxElement(int[]);
int GetMinElement(int[]);

const unsigned int Array_Size = 10;

// =================
int main() {

void Fill();
void SumArray();
int GetMaxElement();
int GetMinElement();




return 0;
}

// ==============
void Fill(int Stuff[]) {

Stuff = 0;

int ii;

for (int ii = 0; ii < Array_Size; ii++) {

Stuff[ii] = Random(0, 10);
}// for loop


}// Fill Function

// ===========================
void SumArray(int stuff[], int& theSum) {

theSum = 0;
int ii;

while (ii < Array_Size) {
theSum = theSum + stuff[ii];
}
}// SumArray Function

// ==============================
int GetMaxElement(int stuff[]) {

int MaxElement = stuff[0];

for (int jj = 1; jj < Array_Size; jj++) {

if (stuff[jj] > MaxElement) {
MaxElement = stuff[jj];

}// for loop
return MaxElement;
}// Function GetMaxElement

}// Function GetMaxElement

// ===========================
int GetMinElement(int stuff[]) {

int MinElement = stuff[0];

for (int jj = 1; jj < Array_Size; jj++) {

if (stuff[jj] < MinElement) {
MinElement = stuff[jj];

}// for loop
return MinElement;
}// Function GetMinElement

}// End of GetMin
1.
1
2
3
4
5
6
7
8
9
void SumArray(int stuff[], int& theSum) {

theSum = 0;
int ii;

while (ii < Array_Size) {
theSum = theSum + stuff[ii];
}
}// SumArray Function 


It should be :
1
2
3
4
5
6
7
8
9
void SumArray(int stuff[], int& theSum) {

theSum = 0;
int ii = 0;

while (ii < Array_Size) {
theSum = theSum + stuff[ii]; ii++;
}
}// SumArray Function 


2.
1
2
3
4
5
6
7
8
9
int main() {

void Fill();
void SumArray();
int GetMaxElement();
int GetMinElement();

return 0;
}

Sorry, your code does not really compile.
Last edited on
Topic archived. No new replies allowed.