Welcome Guest. Sign in or Signup

1 Answers

p54.c:19: warning: implicit declaration of function `fibonacci' in gcc?

Asked by: 115 views , , , , , , , , ,

when ii try to compile this small i get : p54.c:19: warning: `fibonacci’

what did i do wrong?

/***************************************************************************/

#include &;.h>

int main ( , char *[ ] ) {

int n ;

("\nplease enter a number\n") ;

("%d" , &;n) ;

fibonacci(n);

return 0 ;
}

int fibonacci(int n) {

=0 ;

int d =1 ;

int sum ;

int i ;

for(i = 0 ; i < n ; i++) {

printf("%d\n",c) ;

sum = c + d ;

c = d ;

d = sum ;

}

return 0 ;

}

Tags: , , , , , , , , , ,

Related posts

1 Answers



  1. jplatt39 on Jul 17, 2011

    What I see as a problem is you don’t have a function prototype above where you call fibonnacci.

    Put:

    int fibonacci(int n);

    ABOVE int main() so that when main calls it the compiler knows what it is talking about.


Answer Question

Get Adobe Flash player