#include <iostream>
#include <cstdlib>

using namespace std;

int randomnumbersarray[100];
int sort_array();

int main()
{int sort_array(int* nums);
int nums[100], p, q, t, size=100;

for (p=1; p<size; p++) {
for (q=size-1; q>=p; q--) {
if (nums[q-1] < nums[q]) {
t = nums[q-1];
nums[q-1] = nums[q];

nums[q] = t;

int randomnumbersarray[100], h;

for (h=0; h<100; ++h) {
randomnumbersarray[h] = (int)(rand()%250);

cout << randomnumbersarray[h] << " ";


return 0;


the error im getting is "undefined reference to `sort_array(int*)' "

the program is meant to had randoom numbers in an array and then a function that sorts the random numbers,
Any help at all please!!!
The function sort_array does not exist. It has not been written.

This int sort_array(); declares the existence of a function named sort_array that takes no parameters and returns an int, and this int sort_array(int* nums); declares the existence of of a function named sort_array that takes an int pointer and returns an int.

Nowhere in this code are these functions actually defined. I suspect you've kind of tried to define the function right at the start of the main function. This is wrong. You cannot define a function inside another function.

You need to read up on how to write functions:
move int sort_array(int* nums) (and the code belonging to it) outside main(). At the end of int sort_array(int* nums) place a { and not a ;

int sort_array(); is a prototype and must match the the implementation, i.e. int sort_array(int* nums).

do not define randomnumbersarray twice.

Please use code tags: [code]Your code[/code]
Topic archived. No new replies allowed.