C language में, Recursion एक प्रक्रिया है जिसमें एक function अपने आप को बार-बार call करता है. इस function को recursive function कहते हैं. इस प्रकार की function call को recursive calls कहा जाता है.
Recursive functions बहुत सारीं mathematical problems को solve करने में बहुत उपयोगी होती है जैसे कि – एक number के factorial को calculate करना, fibonacci series को जनरेट करना आदि.
Advantage
of Recursion in Hindi – रिकर्शन के लाभ
1.
यह अनावश्यक function call को कम करता है.
2.
इसके द्वारा हम problems को आसानी से
solve कर सकते है क्योंकि iterative solution बहुत बड़ा और
complex (कठिन) होता है.
3.
यह हमारे code को elegant (सुंदर) बना देता है.
Disadvantage
of Recursion in Hindi
1.
Recursion का प्रयोग करके बनाये गये
program को समझना और debug करना मुश्किल होता है.
2.
इसके लिए हमें ज्यादा memory space की आवश्यकता होती है.
3.
इसमें program को execute करने में ज्यादा समय लगता है.
इसके प्रकार निम्नलिखित हैं:-
1:- Tail Recursion – यदि एक
recursive function खुद को call करता है और यह recursive call, फंक्शन का अंतिम
statement है तो इसे tail रिकर्शन कहते हैं. इस
recursive call के बाद फंक्शन कुछ भी perform नहीं करता है.
2:- single recursion – इस प्रकार के रिकर्शन में केवल एक
recursive call होती है.
3:- Multiple recursion – इस प्रकार के रिकर्शन में बहुत सारीं
recursive calls होती हैं.
4:- indirect recursion – यह रिकर्शन तब घटित होता है जब एक
function दूसरे function को call करता है जिसके कारण उसे
original function को call करना पड़ता है.
Recursion का syntax –
इसका
basic syntax नीचे दिया गया है:-
void
recurse()
{
recurse();
}
int main()
{
recurse();
}
Recursion:-The
functuion call itself is known as recursive function and the process is known
as recursion
1 Write a program to
calculate the factorial of given number using recursive function
#include<stdio.h>
#include<conio.h>
int fact(int n)
{
int f;
if (n==1)
{
return(1);
}
else
{
f=n*fact(n-1);
}
return(f);
}
void main()
{
int num=1;
int ans=fact(num);
printf("%d",ans);
getch();
}
2.Write a program to
calculate the su of n natural number using recursive function
#include<stdio.h>
#include<conio.h>
int sum(int n)
{
int s;
if (n==1)
{
return(1);
}
else
{
f=n+sum(n-1);
}
return(f);
}
void main()
{
int num=1;
int ans=sum(num);
printf("%d",ans);
getch();
}


Welcome to OnlineGuru2020.blogspot.com, your number one source for all things related to Online Education. We're dedicated to providing you the very best of Digital Education, with an emphasis on E-notes,Download Links in PDF and youtube videos etc
OnlineGuru2020 Founded in [2020] by Sapan Kumar Das (Asst. Proff Ramchandi College Saraipali), OnlineGuru2020.blogspot.com has come a way from its beginnings .When I first started, my passion inspired me to start my own blog, seeing the need for students in lockdown2020
We hope you enjoy our products as much as we enjoy offering them to you. If you have any questions or comments, please don't hesitate to contact us.
Contact Datails:-
Mobile Number:-9826026747
Email:-sapam.online@gmail.com
Sincerely,
Sapan Kumar Das
.
No comments:
Post a Comment