recursion

U

user923005

What is recursion in C?
Recursion is when a routine calls itself. The C language is
irrelevant, except that C is capable of recursion and some languages
are not capable of recursion.
What advantage is there in its use?
It may lead to simpler code.
 
B

Beej Jorgensen

What is recursion in C? What advantage is there in its use?

It can help you write stories!

-Beej

#include <stdio.h>

void tell_story(void)
{
printf("It was a dark and stormy night. "
"We were standing on the deck. "
"The ship was sinking. The Captain turned to me and said, "
"\"Tell me a story, my son.\" "
"And so I began: ");

printf("'");
tell_story();
printf("'");
}

int main(void)
{
tell_story();
return 0;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top