(adsbygoogle = window.adsbygoogle || []).push({}); 1. The problem statement, all variables and given/known data

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.

2. Relevant equations

3. 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[];

}

]

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Homework Help: Numerical Array split

**Physics Forums | Science Articles, Homework Help, Discussion**