- #1
lcam2
- 28
- 0
Homework Statement
Define an array with 100 integer values, and fill the array with random numbers in the range from 0-99. Then write a function named split () that reads the array and places numbers from 0-50 and another array that places numbers from 50 to 99.
I wrote this code which sets up an array 100 large and generates random numbers every time i run the code. Now i need to create the split function. I need help creating the split function and making it to split of numbers over and under 50.
Any Help is appreciated, thanks in advance.
Homework Equations
The Attempt at a Solution
code
[
#include <iostream>
#include <time.h> //to generate Random Numbers
using namespace std;
//Funtion Prototype
int loadArray ( int [], int);
void printArray (int [], int);
int splitOver50 ( int[], int[], int);
int main ()
{
const int MAX_SIZE = 100;
int numbers [MAX_SIZE]; //Array size 100
int A, over50, sizeOver;
loadArray ( numbers, MAX_SIZE); //Calling loadArray function
printArray ( numbers, MAX_SIZE); //Calling printArray Function
sizeOver = splitOver50 ( A[] , over50[] , MAX_SIZE );
cout << sizeOver << endl;
return 0;
}
void printArray (int A[], int MAX_SIZE) //printArray Function
{
int i;
for ( i=0; i<MAX_SIZE; i++)
cout << A << endl;
}
//Functions
int loadArray ( int A[], int MAX_SIZE) //LoadArray Funciton
{
//fill with random numbers
int i,randomNumber;
srand (time (NULL) ); //Initialize random nubmer generator
for ( i=0; i < MAX_SIZE; i ++)
{
randomNumber = rand() % 100; // get random numbers; range 0-99
A= randomNumber;
}
return 0;
}
int splitOver50 ( int A[], int over50[], int MAX_SIZE )
{
if (A > 50 )
{
over50 =A;
}
return over50[];
}
]