Example of recursion in c programming


C programs on recursion. Collections of function recursion programs source code examples in c programming language frequently asked in interview 


Sum of n numbers using recursion in c

41 comments:

Anonymous said...

The best c site i have ever seen in my life

Anonymous said...

ya best site......

Anonymous said...

Nice site. Very good for beginners....

alka,siya,preema said...

one of the best site.....

ranjinimenon12 said...

loved this site.....thumbs up to the ppl who created this...
the best site... :)

sajeev kr said...

really great site

Anonymous said...

haa were are u from???

Arvind said...

yes this is best c site which contains useful data.

Anonymous said...

really THE BEST site for c learners............thanks a lot to the one who created this site

Abhishek Malhotra said...

whoever created this site looked at every aspect of a problem
a great site for c learners

thank u :)

Anonymous said...

_/\_ for this site and creator...

Anonymous said...

the best c programming and very flexible answers

Anonymous said...

write a C program for Tower of Hanoi problem with a example of 4 disks .

Chayan Ghosh said...

best site for ever..............very very helpful for all level programmers ....thank you sir

Rashedul said...

great site it is....thank u sir...

ranjith said...

thank very much author

Anonymous said...

I think so

Sebin Mathew said...

really helpful

Anonymous said...

hello everbody ,
i am having doubt in tower of hanoi .i tried every site for understanding tower of hanoi
but none worked.
following is the program


#include "stdio.h"

void towers(int,char,char,char);

void towers(int n,char frompeg,char topeg,char auxpeg)
{ /* If only 1 disk, make the move and return */
if(n==1)
{ printf("\nMove disk 1 from peg %c to peg %c",frompeg,topeg);
return;
}
/* Move top n-1 disks from A to B, using C as auxiliary */
towers(n-1,frompeg,auxpeg,topeg);
/* Move remaining disks from A to C */
printf("\nMove disk %d from peg %c to peg %c",n,frompeg,topeg);
/* Move n-1 disks from B to C using A as auxiliary */
towers(n-1,auxpeg,topeg,frompeg);
}
main()
{ int n;
printf("Enter the number of disks : ");
scanf("%d",&n);
printf("The Tower of Hanoi involves the moves :\n\n");
towers(n,'A','C','B');
return 0;
}

In the function tower ,there has been 2 recursive function call,does the statement below 1st
recursive function gets executed if yes then how?
please explain step wise as i am new to programming.
Regards

Anonymous said...

ultimate site for c learners !!!!

Anonymous said...

Thank you... It helped me a lot!!!

Amit said...

Great.. thank you very much

Anonymous said...

Comment should not be empty

hari vijay singh Chandel said...

Can anyone tell me about the best site for c++ and data structure as this site is for c????. thankss

Anonymous said...

really it is best!!!
it helps always..

sharanya Jp said...

really awestruck site i had ever seen for learning c..!! thanks alot.

Madhu said...

SUPERB SITE!!!! THANK U SO MUCH.I WAS ABLE TO FIND ALL THE SOLUTIONS FOR ALL C PROGRAMS!!! :-D

dimitrisfra said...

hello anyone to sugegst me book with solved exercises in recutions??i be grateful for that help!!thanks

dimitrisfra said...

?
/and list of best books with solved problems in data structurs using c

Anonymous said...

#include
void move(int n,char s,char d)
{
printf("Move the %d plate from %c to %c\n",n,s,d);

}
void toh(char s,char d,char u,int n)
{
if(n!=0)
{
toh(s,u,d,n-1);
move(n,s,d);
toh(u,d,s,n-1);
}
else
return;

}
void main()
{
toh('A','B','C',4);

}

Anonymous said...

very very helpful........thankyou for creating this site
helped me a lot........._/\_ thank you

Mau Zhing said...

1) Write a program with dedicated functions to find the sum of the following series:
a. 2, 5, 7, . . ., 2N + 1
b. -2, 4, 46, . . ., 6n3 – 2
Note that the functions must be written as a recursive functions.
how to solve this?

Mau Zhing said...

2) Write a program to solve the following algebraic formula in a recursive form.

y = 1 – x + x2/2 – x3/6 + x4/24 + . . . + (-1)nxn/n!

You may have to write and use a factorial function in this program.
Note that the factorial function must also be written as a recursive function.

Rupak Rijal said...

Write a programme to generate:
A
A B
A B C
A B C D
A B C D E

Kaustav Roy Choudhury said...

#include
#include /*for getch()*/
void main()
{
int n;
int k;
int i;
printf("\n enter the no of rows");
scanf("%d",&n);
for (i=0;i<n;i=i+1)
{
printf("\n");
for (k='A';k<='A'+i;k=k+1)
printf("%c",k)
}
getch();
}

Alimadi Kenneth said...

Hey guys, please help me to write the c program that tell a person how to drive an manual car.

Alimadi Kenneth said...

what are the real life applicability of the recursion in c programming

Rakib Rhm said...

this is the best C site.here everything is details.........

Unknown said...

best site for C programming

Waqar Ali said...

yeah www.google.com

rencel john said...

help me pls to create a C program language that will display your name,program,course, section, semester,shool,year,and instructor.. help me pleas pls pls and thakns