Can anybody say what should i write in the last "return"? Cause if i try to compile my program i have this error: " helpers.c:50:5: error: void function 'sort' should not return a value [-Wreturn-type] return false; ^ ~~~~~ 1 error generated."
Here is my code:
/** * helpers.c * * Helper functions for Problem Set 3. */
include
include
include "helpers.h"
/**
Returns true if value is in array of n values, else false.
bool search(int value, int values[], int n)
{
if(n>=0)
{
for(int i=0;i<n;i++)
{
if (values[i]==value)
{
return true;
}
else
{
return false;
}
}
}
return false;
}
/**Sorts array of n values.
void sort(int values[], int n)
{
int min;
for(int j=0;j<n-1;j++)
{
for (int i=0;i<n;i++)
{
if (values[i]>values[i+1])
{
min=values[i+1];
values[i+1]=values[i];
values[i]=min;
}
}
}
return false;
}