2 Replies - 5854 Views - Last Post: 18 December 2012 - 05:50 AM Rate Topic: -----

#1 coolbud012  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 01-July 11

Difference between recursion and function

Posted 18 December 2012 - 03:38 AM

Hey guys I am not new to programming but I really dont know the difference between recursion or function...I know these are the basic things so thats why I want to clear them. Also are there functions used in java or those are called methods in java?

Now coming to C, I wrote a program of factorial in C. First I wrote it using loops, alright then I thought of writing it through recursion and what I end up with was making a program of factorial using functions, I really dont know the basic difference... If someone have basic notes or some link from where I can read more basic concepts then please provide me. Even I tried google but didnt get any useful result.

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Difference between recursion and function

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6107
  • View blog
  • Posts: 23,663
  • Joined: 23-August 08

Re: Difference between recursion and function

Posted 18 December 2012 - 04:08 AM

Factorial tutorial with recursion
Was This Post Helpful? 0
  • +
  • -

#3 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2153
  • View blog
  • Posts: 3,315
  • Joined: 21-June 11

Re: Difference between recursion and function

Posted 18 December 2012 - 05:50 AM

A function (in the C sense) is something that's defined using the syntax type function_name(parameter_list) { body }. A recursive function is a function that calls itself within the body of the function. So recursion is the act of a function calling itself within its body.

So yes, if you solve a problem using recursion, you're going to be using functions as there is no recursion without functions (of course there's no C program at all without functions either...).
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1