|
|
#1 | ||
|
(╯°□°)╯︵ ┻━┻
Join Date: Dec 2006
Location: United States
Posts: 5,956
|
Here is the assignment description
Quote:
Code:
#include <iostream>
#include <cstdlib>
using namespace std;
void fill_with_random_data (int*, int);
void print_array (int*, int);
int main()
{
const int size = 10;
int random_array[size] = {};
fill_with_random_data (random_array, size);
print_array (random_array, size);
}
void fill_with_random_data (int *random_array, int size)
{
for (int i=0; i<size; i++)
{
srand(time(0));
random_array[i] = rand() % 1410;
}
}
void print_array (int* random_array, int size)
{
for (int i=0; i<size; i++)
{
cout <<"Array contents are: " << random_array[i] << ' ' << &random_array[size] << '\n';
}
}
Quote:
Code:
// CSCI 1410 Programming assignment 6
// Written by FIRSTNAME LASTNAME <EMAIL>
#include <iostream>
#include <cstdlib>
using namespace std;
int* find_smallest_number(int*, int);
void fill_with_random_data(int*, int);
void print_array(int*, int);
int main()
{
const int size = 10;
int random_array[size] = {};
fill_with_random_data(random_array, size);
print_array(random_array, size);
int* smallestNumber = find_smallest_number(random_array, size);
if (smallestNumber < &random_array[0] || smallestNumber > &random_array[size])
{
cout << "ERROR : The pointer returned is outside the random array!" << endl;
}
else
{
cout << "The smallest item is " << *smallestNumber;
cout << " and it is at memory location is " << smallestNumber << endl;
}
}
// This function takes an array and fills it with random numbers
// between 0 and 1410. It also seeds the random number generator to
// ensure reasonable random numbers.
void fill_with_random_data(int *random_array, int size)
{
//
//
// IMPLEMENTATION GOES HERE
//
//
}
// This function returns a pointer to the smallest number in
// the array.
int* find_smallest_number(int *random_array, int size)
{
//
//
// IMPLEMENTATION GOES HERE
//
//
}
// This function prints every value of the array along with
// the memory location.
void print_array(int *random_array, int size)
{
//
//
// IMPLEMENTATION GOES HERE
//
//
}
__________________
Desktop -Cooler Master NV690/AMD Phenom II X4 965 BE/MSI 880G-E45 Motherboard/2 x 2GB DDR3 G.Skill Ripjaws X/Sapphire HD 5870 1GB GDDR5/CORSAIR CMPSU-550VX/Seagate 7200.12 500GB (OS), Samsung F3 1TB (Storage)/Sony DVD Burner/Windows 7 Professional 64-bit |
||
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|