so i have to write a code that generates a number from 25-100 (x) and this will be the index of my array. i then need to x numbers from 1-1000 and store them as the element of my array. that is the first function. in the second function i need to write a code that returns the location of the smallest element, in the third function i need to write a code that returns the location of the largest element and in the last function i need to print the largest and smallest number. this is what i have right now..and am stuck. Someone plss help me!!

#include <iostream>
#include <ctime>
#include <cstdlib>

using namespace std;
int num2;
int loadArray (int);
int smallestLocation (int);
int largestLocation (int);
void printSmallestLargest (int);
int main ()
int max = 0;
int number = 0;
return 0;

int loadArray (int maximumNumber[])
int maxNumber;
maxNumber =  rand()%76 + 25 ;
for(int i = 0; i<=maxNumber; i++)
int values =  rand()%1000 + 1 ;
for(int j = 0; j<=maxNumber; j++)
maximumNumber  = j;
return maxNumber;

int smallestLocation (int small[])

Let me see if I understand.
The first number is a RANDOM number between 25-100.
That number will be used to create THAT NUMBER of random numbers between 1-1000.

Then you need the index of the smallest number
Then you need the index of the largest number
Then you need to print the value of the smallest and the value of the largest.

Is that right?

Does what you have work? That's your first step. Don't try writing the whole thing at once.

Get LoadArray() working well first. Output the entire array at the end of main() And use CODE tags.

This article has been dead for over six months. Start a new discussion instead.