Help with function that print odd, even, prime, perfect square using arrays.

The program is to print:
- number 5 129 times
- even numbers until 200
- odd numbers until 200
- perfect square of 1 to 50
- prime numbers of 350.

I think i may need to pass the functions by reference but do not know how to go about that.
Here is what i have so far:

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

void loadArrayOf5s(int array, int length);
void printArray(int myarray[], int length, int = 5);
void loadEvenArray(int array, int length);
void loadOddArray(int array[], int length);
void loadPSA(int array[], int length);
void loadPrimeArray(int myarray[], int length);

int main()
{
const int SIZE = 129;
int MyArray[SIZE];

cout << "\n\t\t This is a lab on completely filled arrays \n"
<< "\t\t by Charlene Magang \n\n\n";

cout << "I am about to call loadArrayOf5s ... \n"
<< "Finished loading loadArrayOf5s ... \n"
<< "I am about to call printArray (with the default value for the perLine)... \n";
loadArrayOf5s(MyArray, SIZE);
printArray(MyArray, SIZE);

cout << "\n\n";
system("pause");

cout << "I am about to call loardEvenArray ... \n"
<< "Finished loading EvenArray ... \n"
<< "I am about to call printArray (with 4 perLine)... \n";
loadEvenArray(MyArray, 188);
printArray(MyArray, SIZE, 4);

cout << "\n\n";
system("pause");

cout << "I am about to call loadOddArray ... \n"
<< "Finished loading OddArray ... \n"
<< "I am about to call printArray (with 3 perLine)... \n";
loadOddArray(MyArray, 189);
printArray(MyArray, SIZE, 3);

cout << "\n\n";
system("pause");

cout << "I am about to call loadPSA ... \n"
<< "Finished loading loadPSA ... \n"
<< "I am about to call printArray (with 1 perLine)... \n";
loadPSA(MyArray, 42);
printArray(MyArray, SIZE, 1);

cout << "\n\n";
system("pause");

cout << "I am about to call loadPrimeArray ... \n"
<< "Finished loading PrimeArray ... \n"
<< "I am about to call printArray (with 1 perLine)... \n";
loadPrimeArray(MyArray, 660);
printArray(MyArray, SIZE, 1);

cout << "\n\n";
system("pause");
}

//****************** loadArrayOf5s **************
void loadArrayOf5s(int array[], int length)
{
for (int i = 0; i < length; i++)
array[i] = 5;
}

//****************** printArray *****************
void printArray(int myarray[], int length, int x)
{
int j = 1;
for (int i = 0; i < length; i++)
cout << myarray[i] << (j++ % x ? "\t" : "\n");
}

//****************** loadEvenArray **************
void loadEvenArray(int array[], int length)
{
for (int i = 1; i < 200; i++)
array[i] = 2 * i;
}

//****************** loadOddArray **************
void loadOddArray(int myarray[], int length)
{
int number = 0;
for (int i = 0; i < 200; i++)
if (myarray[i] % 2 != 0);
number++;
return static_cast <void> (number);
}

//****************** loadPSA **************
void loadPSA(int myarray[], int length)
{
for (int i = 1; i <= 42; i++)
myarray[i] = i*i;
}

//****************** loadPrimeArray **************
void loadPrimeArray(int myarray[], int length)
{
int count = 0;
for (int i = 1; i <= length; i++)
{
if (length % i == 0)
count++;
}
if (count == 2)
myarray[i] = length;
}
Please use code tags: [code]Your code[/code]
Read this: http://www.cplusplus.com/articles/z13hAqkS/

What is the problem?
Topic archived. No new replies allowed.