LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-28-2004, 08:24 PM   #1
shams
Member
 
Registered: Jan 2004
Posts: 396

Rep: Reputation: 30
Unhappy error recursive function in c


hi,
This is a recursive function code:
#include <stdio.h>
main()
{
int a, fact;

printf("\nEnter any number\n");
scanf("%d",&a);

fact=rec(a);
printf(" Factorial value of %d is %d\n",a,fact);

}
rec(x)
int x;
{
int f;

if(x==1)
retrun(1);
else
f=x*rec(x-1);
return(f);

}
and this is the compiling error:
[root@localhost lbin]# gcc -o l152 l152.c
/root/tmp/ccGiALkv.o(.text+0x6f): In function `rec':
: undefined reference to `retrun'
collect2: ld returned 1 exit status
plz tell me where is the error and is there any deference for dos and linux enviroments?
 
Old 07-28-2004, 08:28 PM   #2
SirSlappy
Member
 
Registered: Jun 2003
Location: Glendale AZ
Distribution: Slackware 10
Posts: 153

Rep: Reputation: 30
int main ()


??
 
Old 07-28-2004, 08:40 PM   #3
AltF4
Member
 
Registered: Sep 2002
Location: .at
Distribution: SuSE, Knoppix
Posts: 532

Rep: Reputation: 31
"retrun" should be "return"
 
Old 07-28-2004, 08:44 PM   #4
SirSlappy
Member
 
Registered: Jun 2003
Location: Glendale AZ
Distribution: Slackware 10
Posts: 153

Rep: Reputation: 30
DOH! LOL.

I looked at that, but only looked at the second return and assumed it was okay.

Yeh, you mispelled "return"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl file handler in recursive function enemorales Programming 4 02-02-2009 03:20 PM
using return in recursive function hubabuba Programming 9 10-10-2005 09:59 AM
make :recursive error appasamy Linux - Software 1 01-03-2005 12:01 AM
gcc: recursive function quirk Disruptor Linux - Software 0 03-31-2004 11:58 AM
Recursive Function TriggerJ Programming 4 02-02-2004 08:58 PM


All times are GMT -5. The time now is 09:57 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration