Results 1 to 3 of 3
Hello, I'm new to Programming C just started my first steps.
In the program i will provide below I can't seem to find what the error is.
The error I ...
- 03-03-2010 #1Just Joined!
- Join Date
- Mar 2010
- Posts
- 2
I can't seem to find what the problem is...
Hello, I'm new to Programming C just started my first steps.
In the program i will provide below I can't seem to find what the error is.
The error I get is this /tmp/ccMNZGEy.o: In function `main':
median.c: (.text+0x48 ): undefined reference to `findmedian'
collect2: η ld επέστρεψε κατάσταση εξόδου (this means that it returned as output) 1
I would appreciate your help!
Code:#include <stdio.h> #include <stdlib.h> #define N 7 float findMedian(float x[],int n); main() { int i; float x[N],r; for(i=0;i<N;i++){ x[i]=rand(); } r=findmedian(x[N],N); for(i=0;i<N;i++){ printf(" %f \t", x[i]); } printf(" \n "); printf(" %f ", r); } float findMedian(float x[],int n) { int i,j,k,temp; for(i=(n-1);i>=0;i--) { for(j=1;j<=i;j++){ if(x[j-1]>x[j]){ temp=x[j-1]; x[j-1]=x[j]; x[j]=temp; } } } return(x[4]); }
- 03-03-2010 #2Linux User
- Join Date
- Nov 2009
- Location
- France
- Posts
- 292
I can't say I know C but there is 1 typo error and 1 argument passing error :
Code:r=findmedian(x[N],N); r=findMedian(x,N);
0 + 1 = 1 != 2 <> 3 != 4 ...
Until the camel can pass though the eye of the needle.
- 03-03-2010 #3Just Joined!
- Join Date
- Mar 2010
- Posts
- 2
Thanks a ton. It seems I'm going blind as the time goes by.


Reply With Quote