JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi sociology physics physical education maths english economics geography History

chemistry business studies biology accountancy political science

Class 12

Hindi physics physical education maths english economics

chemistry business studies biology accountancy Political science History sociology

Home science Geography

English medium Notes

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Class 12

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Categories: C Language in hindi

C : Recursion : Examples in c programming language in hindi , Recursion example programs

Recursion example programs , C : Recursion : Examples in c programming language in hindi :-
इससे पहले के article मे , recursion से related उदाहरण को discuss किया था |अब इस article मे , recursion से related पांच और उदाहरन को पढ़गे |
उदाहरण -1
Write a program to print strong numbers in range .
इस उदाहरण मे , recursion process से किसी range के सभी strong numbers को print करते है |
Explanation
Strong number  एसी number होती है जिसका factorial का sum ,number के equal होता है |
1.सबसे पहले , यूजर से range की start और end को input करा लेते है |
2.इसके बाद function print() को call करते है जिसमे start और end को pass करते है |
print() मे ,
अगर start की value end से कम नहीं होती तब , number को start से initial करते है |इसके बाद loop चलाया जाता है |
1.जब तक number के value ‘0’ नहीं होती है तब sum operation perform करते है |
sum operation मे , recursion प्रोसेस मे fact() function को call करेगे और इस function मे number = number /10 से डिवाइड करेगे |
2.जब start के value sum से सामान होती है तब start को print करेगे |
fact () function मे ,
अगर num की value 0 होती है  तब ‘1’ return होगा |
अन्यथा रिकर्शन process से fact () function को call करेगे |
Source Code
#include<stdio.h>
#include<conio.h>
int fact(int number);
void print(int , int );
void main()
{
int start, end;
printf(“Enter Start “);
scnaf(“%d”,&start);
printf(“Enter End”);
scnaf(“%d”,&end);
printf(“Strong number in list “);
print(start , end );
getch();
}
void start (int s ,int e )
{
int sum;
int number ;
while(s!=end)
{
sum=0;
number = start ;
while (number!=0)
{
sum = sum + fact (number % 10 );
number = number / 10 ;
}
if(s == sum)
{
printf(“%d”,s );
}
s++;
}
}
int fact ( int num )
{
if(num==0)
{
return 1;
}
else
{
return (num * fact(num -1)) ;
}
उदाहरण -2
Write a program to print reverse of the number  .
इस उदाहरण मे , recursion process से किसी number  को reverse  print करते है |
Explanation
1.सबसे पहले , number को input करा लेते है |
2. उसके बाद reverse() function को call कर लेते है |
reverse function मे ,
इस function मे number को 10 से डिवाइड करते है और इसके remainder को print करते है |
divide function  को call करते है जिसमे number / 10 को pass करते है |
Source Code
#include<stdio.h>
#include<conio.h>
int div(int );
void reverse(int);
void main()
{
int num;
printf(“Enter Number”);
scanf(“%d”, &num);
printf(“Reverse Number”);
reverse(num);
getch();
}
void reverse (int n )
{
int r;
while (n!=0)
{
r=div(n/10);
printf(“%d”,r);
n/10 ;
}
}
int div(int n)
{
return(n % 10 );
}
उदाहरण -3
Write a program to print Fibonacci series  .
इस उदाहरण मे , recursion process से Fibonacci series  print करते है |
Explanation
1.सबसे पहले , Fibonacci series का number elements को input करते है |
2.इसके बाद fib() function को call करते है |इस फ़ुन्क्तिओन्न मे ‘0’ ,’1′ और number of elements को पास कर देगे |
fab() मे ,
1. loop चलाया जाता है | इस loop को जब तक चलाया जाता तब तक i की value size के सामान नहीं हो जाती है
इस loop की body मे , a+b की value को print किया जाता है
recursion process से fab() को call किया जाता है जिसमे a और b के value increment किया जाता है |
Source Code
#include<stdio.h>
#include<conio.h>
int fab(int , int , int );
void main()
{
int l ;
printf(“Enter number of element “);
scanf(“%d”,&l);
fab(0,1,l);
getch();
}
fab(int a , int b ,int len)
{
int i;
for(i=0;i<len;i++)
{
printf(“%d”, a+b));
fab(a++,b++,len)
}
}
उदाहरण -4
Write a program to find nth term of Fibonacci series  .
इस उदाहरण मे , recursion process से nth term of Fibonacci series  find करते है |
Explanation
1.सबसे पहले , यूजर से series मे से किस position के टर्म को find करना है उस position की value input करा लेते है |
2.फिर उसके बाद fab() function कोप call कर लेते है जिसकी value को int f मे assign कर लेते है |
3. इस variable ‘f’ की value को print करा लेते है |
fab() function मे ,
अगर number के value ‘0’ होती है तब ‘0’ return होता है |
अगर number की value ‘1’ होती है तब ‘1’ return होता है |
अन्यथा
रिकर्शन प्रोसेस से function fab() को call कर लेते है जिसमे number-1 और number-2 को pass करा लेते है |
Source Code
#include<stdio.h>
#include<conio.h>
int fab(int );
void main()
{
int l ;
printf(“Enter number “);
scanf(“%d”,&l);
int f;
f=fab(l);
printf(“Nth term of seriers = %d”,f);
getch();
}
int fab(int num)
{
if(num ==0)
{
return(0);
}
else if (num==1)
{
return 1;
}
else
{
return (fab(num-1) +fab(num-2));
}
}
उदाहरण -4
Write a program to find LCM of two numbers.
इस उदाहरण मे , recursion process से  दो number का lCM find करते है |
Explanation
1.सबसे पहले , यूजर से series मे से किस position के टर्म को find करना है उस position की value input करा लेते है |
2.फिर उसके बाद fab() function कोप call कर लेते है जिसकी value को int f मे assign कर लेते है |
3. इस variable ‘f’ की value को print करा लेते है |
fab() function मे ,
अगर number के value ‘0’ होती है तब ‘0’ return होता है |
अगर number की value ‘1’ होती है तब ‘1’ return होता है |
अन्यथा
रिकर्शन प्रोसेस से function fab() को call कर लेते है जिसमे number-1 और number-2 को pass करा लेते है |
Source Code
#include<stdio.h>
#include<conio.h>
int lcm(int ,int );
void main()
{
int a , b , l  ;
printf(“Enter first number “);
scanf(“%d”,&a);
printf(“Enter Second Number”);
scnaf(“%d”,&b);
if(a<b)
{
l=lcm(a,b);
}
else
{
l=lcm(b,a);
}
printf(“LCM = %d”, l );
getch();
}
int lcm(int i ,int j )
{
static int m=0;
m= m +j;
if((m % i = =0) && (m% j ==0)){
return(m);
}
else
{
return lcm(i,j);
}
Sbistudy

Recent Posts

four potential in hindi 4-potential electrodynamics चतुर्विम विभव किसे कहते हैं

चतुर्विम विभव (Four-Potential) हम जानते हैं कि एक निर्देश तंत्र में विद्युत क्षेत्र इसके सापेक्ष…

3 days ago

Relativistic Electrodynamics in hindi आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा

आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा Relativistic Electrodynamics in hindi ? अध्याय : आपेक्षिकीय विद्युतगतिकी…

4 days ago

pair production in hindi formula definition युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए

युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए pair production in hindi formula…

7 days ago

THRESHOLD REACTION ENERGY in hindi देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा

देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा THRESHOLD REACTION ENERGY in hindi…

7 days ago

elastic collision of two particles in hindi definition formula दो कणों की अप्रत्यास्थ टक्कर क्या है

दो कणों की अप्रत्यास्थ टक्कर क्या है elastic collision of two particles in hindi definition…

7 days ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now