Q) C program to findfactorial of number usingrecursionas well as iteration
𝑓𝑎𝑐𝑡𝑜𝑟𝑖𝑎𝑙(𝑛) = {
𝑟𝑒𝑡𝑢𝑟𝑛 1 ; 𝑖𝑓 𝑛 == 0 𝑜𝑟 𝑛 == 1
𝑛
𝑟𝑒𝑡𝑢𝑟𝑛 𝑛 ∗ 𝑓𝑎𝑐𝑡𝑜𝑟𝑖𝑎𝑙( 𝑛 − 1); 𝑖𝑓 𝑛 > 1
Using loops:
factorial=1;
while(n>1)
{
factorial=factorial*n;
n=n-1;
}
Q) Calculate power of a number program in c usingRecursion and Iteration
𝑝𝑜𝑤𝑒𝑟(𝑏, 𝑒) = {
𝑟𝑒𝑡𝑢𝑟𝑛 1; 𝑖𝑓 𝑒 == 0
𝑛
𝑟𝑒𝑡𝑢𝑟𝑛 𝑏 ∗ 𝑝𝑜𝑤𝑒𝑟( 𝑏, 𝑒 − 1); 𝑖𝑓 𝑒 > 0
Explanationwithexample:
53 = 5 ∗ 52 power(5,3) = 5*power(5,2)
power(5,3) = 5 * power(5,3-1) = 5 * power(5,2) = 5*25 = 125
power(5,2) = 5 * power(5,2-1) = 5 * power(5,1) = 5*5 =25
power(5,1) = 5 * power(5,1-1) = 5 * power(5,0) = 5*1 = 5
power(5,0) = 1
Using loops:
power=1;
while(e>0)
{
power=power*b;
e=e-1;
}
Q) Write a C program to count digitsof a number usingRecursion and Iteration.
𝑐𝑜𝑢𝑛𝑡(𝑛) = {
𝑟𝑒𝑡𝑢𝑟𝑛 0; 𝑖𝑓 𝑛 == 0
𝑛
𝑟𝑒𝑡𝑢𝑟𝑛 1 + 𝑐𝑜𝑢𝑛𝑡( 𝑛/10); 𝑖𝑓 𝑛 > 0
Explanationwithexample:
count(872) = 1+count(872/10) = 1+count(87) = 1+2=3
count(87) = 1+count(87/10) = 1+count(8) =1+1 = 2
count(8) = 1+count(8/10) = 1+count(0) =1+0 =1
count(0) = 0
Using loops:
count = 0;
while(n>0)
{
count = count+1;
n=n/10;
}
Q) Write a C program to find sum of firstn natural numbers using Recursion.
𝑠𝑢𝑚(𝑛) = {
𝑟𝑒𝑡𝑢𝑟𝑛 1; 𝑖𝑓 𝑛 == 1
𝑛
𝑟𝑒𝑡𝑢𝑟𝑛 𝑛 + 𝑠𝑢𝑚( 𝑛 − 1); 𝑖𝑓 𝑛 > 1
Explanationwithexample:
sumof first5 natural numbers=
1+2+3+4+5
5+4+3+2+1
5+sum of first4 natural numbers
sumof first4 natural numbers=
4+sum of first3 natural numbers
sumof first3 natural numbers=
3+sum of first2 natural numbers
sumof first2 natural numbers =
2+sum of first1 natural numbers
sumof first1 natural numbers= 1
sum(5) = 5+sum(5-1) = 5+ sum(4) = 10+5 = 15
sum(4) = 4+sum(4-1) = 4+ sum(3) = 6+4 = 10
sum(3) = 3+sum(3-1) = 3+ sum(2) = 3+3 = 6
sum(2) = 2+sum(2-1) = 2+ sum(1) = 2+1 = 3
sum(1) = 1
Using loops:
sum=0
while(n>0)
{
sum=sum+n;
n=n-1;
}
Q. C program to print sum of digitsof a given numberusing recursion
𝑠𝑢𝑚(𝑛) = {
𝑟𝑒𝑡𝑢𝑟𝑛 0; 𝑖𝑓 𝑛 == 0
𝑛
𝑟𝑒𝑡𝑢𝑟𝑛 𝑛%10 + 𝑠𝑢𝑚( 𝑛/10); 𝑖𝑓 𝑛 > 0
Explanationwithexample:
sum(872) = 872%10 + sum(872/10) = 2+sum(87) = 2+15= 17
sum(87) = 87%10 + sum (87/10) = 7+sum(8) = 7+8 = 15
sum(8) = 8%10 + sum (8/10) = 8+sum(0) = 8+0 = 8
sum(0) = 0
Q. Write a C program to findnth term in Fibonacci Seriesusing Recursion.
𝑓𝑖𝑏(𝑛) = {
𝑟𝑒𝑡𝑢𝑟𝑛 0; 𝑖𝑓 𝑛 == 1
𝑟𝑒𝑡𝑢𝑟𝑛 1; 𝑖𝑓 𝑛 == 2
𝑟𝑒𝑡𝑢𝑟𝑛 𝑓𝑖𝑏( 𝑛 − 1) + 𝑓𝑖𝑏( 𝑛 − 2); 𝑖𝑓 𝑛 > 2
Q. C program to find out the GCD (GreatestCommonDivisor )ofthe two numbers usingrecursion
𝑔𝑐𝑑 (𝑎, 𝑏) = {
𝑟𝑒𝑡𝑢𝑟𝑛 𝑎; 𝑖𝑓 𝑏%𝑎 == 0
𝑛
𝑟𝑒𝑡𝑢𝑟𝑛 gcd( 𝑏%𝑎, 𝑎) ; 𝑖𝑓 𝑏%𝑎 ! = 0
Explanationwithexample:
Sample Input:8 12
Sample Output:4
8 ) 12 ( 1
8
---------
4 ) 8 ( 2
8
-------
0
--------
gcd(8,12) =gcd(12%8 , 8) = gcd( 4, 8) = 4
gcd(4,8) = 4
Full Program:
#include <stdio.h>
intprint(intn)
{
if(n<= 2)
printf("%d",n%2);
else
{
print(n/2);
printf("%d",n%2);
}
}
intmain()
{
int n;
printf("enteranumber");
scanf("%d",&n);
print(n);
}
Q. Write a C program to findthe first uppercase letterin the givenstring usingrecursion.Sample
Input : kl University
Sample Output: U
𝑠𝑒𝑎𝑟𝑐ℎ(𝑠𝑡𝑟, 𝑖) = {
𝑟𝑒𝑡𝑢𝑟𝑛 − 1; 𝑖𝑓 𝑠𝑡𝑟[𝑖] == ′0′
𝑟𝑒𝑡𝑢𝑟𝑛 𝑖; 𝑖𝑓 𝑠𝑡𝑟[𝑖] == ′𝑈′
𝑟𝑒𝑡𝑢𝑟𝑛 𝑠𝑒𝑎𝑟𝑐ℎ( 𝑠𝑡𝑟, 𝑖 + 1); 𝑖𝑓 𝑠𝑡𝑟[𝑖] ! = ′𝑈′
Q) write C program to calculate lengthof the string usingRecursion
𝑙𝑒𝑛(𝑠𝑡𝑟) = {
0 𝑖𝑓 𝑠𝑡𝑟[0] == ′0′
𝑛
1 + len(string left after removing first character) 𝑖𝑓 𝑠𝑡𝑟[0] ! = ′0′
Explanationwithexample:
lengthof string“abc” = 1+ lengthof string“bc”
lengthof string“bc” = 1+ lengthof string“c”
lengthof string“c” = 1+ lengthof string“0”
lengthof string“0” = 0
Q) Write a program in C to count numberof divisorsof a givennumberusing recursion
𝑐𝑜𝑢𝑛𝑡(𝑛, 𝑖) = {
𝑟𝑒𝑡𝑢𝑟𝑛 1; 𝑖𝑓 𝑖 == 𝑛
𝑟𝑒𝑡𝑢𝑟𝑛 1 + 𝑐𝑜𝑢𝑛𝑡( 𝑛, 𝑖 + 1) ; 𝑖𝑓 (𝑛%𝑖 == 0)
𝑟𝑒𝑡𝑢𝑟𝑛 𝑐𝑜𝑢𝑛𝑡( 𝑛, 𝑖 + 1); 𝑖𝑓(𝑛%𝑖 ! = 1)
Using loops:
for(i=1;i<=n;i++)
{
If(n%i ==0)
{
count=count+1;
}
}
Recursive programtocheck whetheragivennumberisprime orcomposite.
#include <stdio.h>
intcount(intn,inti)
{
if(i == n)
return1;
else if(n%i==0)
return1+count(n,i+1); //1+count of divisorsfromi+1 to n if i isdivisor
else if(n%i!=0)
returncount(n,i+1); // count of divisorswontchange if i isnot divisor
}
intmain()
{
int n;
printf("enteranumber");
scanf("%d",&n);
int c=count(n,1);//count of divisorsfrom1 to n
if(c== 2)
printf("prime");
else
printf("composite");
}
Q. C program to displays integers100 through 1 usingRecursion and Iteration
𝑑𝑖𝑠𝑝𝑙𝑎𝑦(𝑛) = {
𝑝𝑟𝑖𝑛𝑡𝑓(%d, 𝑛); 𝑖𝑓 𝑛 == 1
𝑛
𝑝𝑟𝑖𝑛𝑡𝑓(%d, 𝑛); 𝑑𝑖𝑠𝑝𝑙𝑎𝑦( 𝑛 − 1); 𝑖𝑓 𝑛 > 1
Q. Write a program in C to converta decimal number to binary usingrecursion.
Sample Input : 66
Sample Output: 1000010
𝑑𝑒𝑐𝑡𝑜𝑏𝑖𝑛(𝑛) = {
𝑝𝑟𝑖𝑛𝑡𝑓("%d", 𝑛%2); 𝑖𝑓 𝑛 ≤ 2
𝑛
𝑑𝑒𝑐𝑡𝑜𝑏𝑖𝑛( 𝑛/2); 𝑝𝑟𝑖𝑛𝑡𝑓("%d", 𝑛%2); 𝑖𝑓 𝑛 > 2
Full program
#include <stdio.h>
intdectobin(intn)
{
if(n<= 2)
printf("%d",n%2);
else
{
dectobin(n/2);
printf("%d",n%2);
}
}
intmain()
{
int n;
printf("enteranumber");
scanf("%d",&n);
dectobin(n);
}
RecursionStackof factorial of 3
intfactorial(1)
{
if(1== 0 || 1==1)
return1;
else if(n>1)
returnn*factorial(n-1);
}
intfactorial(2)
{
if(2== 0 || 2 ==1)
return1;
else if(2>1)
return2*factorial(2-1);
}
intfactorial(3)
{
if(3== 0 || 3==1)
return1;
else if(3>1)
return3*factorial(3-1);
}
intmain()
{
int n,fact;
printf("enteranumber");
scanf("%d",&n);
fact=factorial(n);//factorial(3)
printf("factorialof %dis%d",n,fact);
}
Recursionstackof 4 th term of Fibonacci
intfib(2)
{
if( 2 == 1)
return0;
else if(2== 2)
return1;
else
returnfib(n -1)+fib(n-2);
}
intfib(1)
{
if( n == 1)
return0;
else if(n==2)
return1;
else
returnfib(n -1)+fib(n-2);}
intfib(2)
{
if( 2 == 1)
return0;
else if(2== 2)
return1;
else
returnfib(n -1)+fib(n-2);
}
intfib(3)
{
if( 3 == 1)
return0;
else if(3== 2)
return1;
else
returnfib(3-1)+fib(3-2);
}
intfib(4)
{
if( 4 == 1)
return0;
else if(4== 2)
return1;
else
returnfib(4-1)+fib(4-2);
}
intmain()
{
int n,term;
printf("entern value");
scanf("%d",&n);
term=fib(n); //fib(4)
printf("%dthtermis%d",n,term);
}
C program to findfactorial of number usingrecursion as well as iteration ,
Calculate power of a number program in c usingRecursion and Iteration,Write a C program to
count digitsof a numberusing Recursionand Iteration, Write a C program to find sum of firstn
natural numbers usingRecursion, C program to printsum of digits ofa givennumber using
recursion,Write a C program to findnth term in Fibonacci SeriesusingRecursion, C program to
findout the GCD (GreatestCommonDivisor )ofthe two numbersusing recursion,
Write a C program to find the first upper case letterin the givenstring using recursion, write C
program to calculate lengthof the string using Recursion,
Write a program in C to count number of divisorsof a givennumber usingrecursion, Recursive
program to checkwhetheragivennumberisprime orcomposite,
C program to displaysintegers100 through 1 using Recursionand Iteration,Write a program in C
to convert a decimal numberto binary usingrecursion,
RecursionStackof factorial of 3 Recursionstackof 4th term of Fibonacci

Recursion in C

  • 1.
    Q) C programto findfactorial of number usingrecursionas well as iteration 𝑓𝑎𝑐𝑡𝑜𝑟𝑖𝑎𝑙(𝑛) = { 𝑟𝑒𝑡𝑢𝑟𝑛 1 ; 𝑖𝑓 𝑛 == 0 𝑜𝑟 𝑛 == 1 𝑛 𝑟𝑒𝑡𝑢𝑟𝑛 𝑛 ∗ 𝑓𝑎𝑐𝑡𝑜𝑟𝑖𝑎𝑙( 𝑛 − 1); 𝑖𝑓 𝑛 > 1 Using loops: factorial=1; while(n>1) { factorial=factorial*n; n=n-1; } Q) Calculate power of a number program in c usingRecursion and Iteration 𝑝𝑜𝑤𝑒𝑟(𝑏, 𝑒) = { 𝑟𝑒𝑡𝑢𝑟𝑛 1; 𝑖𝑓 𝑒 == 0 𝑛 𝑟𝑒𝑡𝑢𝑟𝑛 𝑏 ∗ 𝑝𝑜𝑤𝑒𝑟( 𝑏, 𝑒 − 1); 𝑖𝑓 𝑒 > 0 Explanationwithexample: 53 = 5 ∗ 52 power(5,3) = 5*power(5,2) power(5,3) = 5 * power(5,3-1) = 5 * power(5,2) = 5*25 = 125 power(5,2) = 5 * power(5,2-1) = 5 * power(5,1) = 5*5 =25 power(5,1) = 5 * power(5,1-1) = 5 * power(5,0) = 5*1 = 5 power(5,0) = 1 Using loops: power=1; while(e>0) { power=power*b; e=e-1; } Q) Write a C program to count digitsof a number usingRecursion and Iteration. 𝑐𝑜𝑢𝑛𝑡(𝑛) = { 𝑟𝑒𝑡𝑢𝑟𝑛 0; 𝑖𝑓 𝑛 == 0 𝑛 𝑟𝑒𝑡𝑢𝑟𝑛 1 + 𝑐𝑜𝑢𝑛𝑡( 𝑛/10); 𝑖𝑓 𝑛 > 0 Explanationwithexample: count(872) = 1+count(872/10) = 1+count(87) = 1+2=3 count(87) = 1+count(87/10) = 1+count(8) =1+1 = 2 count(8) = 1+count(8/10) = 1+count(0) =1+0 =1 count(0) = 0 Using loops: count = 0; while(n>0) { count = count+1; n=n/10; } Q) Write a C program to find sum of firstn natural numbers using Recursion. 𝑠𝑢𝑚(𝑛) = { 𝑟𝑒𝑡𝑢𝑟𝑛 1; 𝑖𝑓 𝑛 == 1 𝑛 𝑟𝑒𝑡𝑢𝑟𝑛 𝑛 + 𝑠𝑢𝑚( 𝑛 − 1); 𝑖𝑓 𝑛 > 1 Explanationwithexample: sumof first5 natural numbers= 1+2+3+4+5
  • 2.
    5+4+3+2+1 5+sum of first4natural numbers sumof first4 natural numbers= 4+sum of first3 natural numbers sumof first3 natural numbers= 3+sum of first2 natural numbers sumof first2 natural numbers = 2+sum of first1 natural numbers sumof first1 natural numbers= 1 sum(5) = 5+sum(5-1) = 5+ sum(4) = 10+5 = 15 sum(4) = 4+sum(4-1) = 4+ sum(3) = 6+4 = 10 sum(3) = 3+sum(3-1) = 3+ sum(2) = 3+3 = 6 sum(2) = 2+sum(2-1) = 2+ sum(1) = 2+1 = 3 sum(1) = 1 Using loops: sum=0 while(n>0) { sum=sum+n; n=n-1; } Q. C program to print sum of digitsof a given numberusing recursion 𝑠𝑢𝑚(𝑛) = { 𝑟𝑒𝑡𝑢𝑟𝑛 0; 𝑖𝑓 𝑛 == 0 𝑛 𝑟𝑒𝑡𝑢𝑟𝑛 𝑛%10 + 𝑠𝑢𝑚( 𝑛/10); 𝑖𝑓 𝑛 > 0 Explanationwithexample: sum(872) = 872%10 + sum(872/10) = 2+sum(87) = 2+15= 17 sum(87) = 87%10 + sum (87/10) = 7+sum(8) = 7+8 = 15 sum(8) = 8%10 + sum (8/10) = 8+sum(0) = 8+0 = 8 sum(0) = 0 Q. Write a C program to findnth term in Fibonacci Seriesusing Recursion. 𝑓𝑖𝑏(𝑛) = { 𝑟𝑒𝑡𝑢𝑟𝑛 0; 𝑖𝑓 𝑛 == 1 𝑟𝑒𝑡𝑢𝑟𝑛 1; 𝑖𝑓 𝑛 == 2 𝑟𝑒𝑡𝑢𝑟𝑛 𝑓𝑖𝑏( 𝑛 − 1) + 𝑓𝑖𝑏( 𝑛 − 2); 𝑖𝑓 𝑛 > 2 Q. C program to find out the GCD (GreatestCommonDivisor )ofthe two numbers usingrecursion 𝑔𝑐𝑑 (𝑎, 𝑏) = { 𝑟𝑒𝑡𝑢𝑟𝑛 𝑎; 𝑖𝑓 𝑏%𝑎 == 0 𝑛 𝑟𝑒𝑡𝑢𝑟𝑛 gcd( 𝑏%𝑎, 𝑎) ; 𝑖𝑓 𝑏%𝑎 ! = 0 Explanationwithexample: Sample Input:8 12 Sample Output:4 8 ) 12 ( 1 8 --------- 4 ) 8 ( 2 8 ------- 0
  • 3.
    -------- gcd(8,12) =gcd(12%8 ,8) = gcd( 4, 8) = 4 gcd(4,8) = 4 Full Program: #include <stdio.h> intprint(intn) { if(n<= 2) printf("%d",n%2); else { print(n/2); printf("%d",n%2); } } intmain() { int n; printf("enteranumber"); scanf("%d",&n); print(n); } Q. Write a C program to findthe first uppercase letterin the givenstring usingrecursion.Sample Input : kl University Sample Output: U 𝑠𝑒𝑎𝑟𝑐ℎ(𝑠𝑡𝑟, 𝑖) = { 𝑟𝑒𝑡𝑢𝑟𝑛 − 1; 𝑖𝑓 𝑠𝑡𝑟[𝑖] == ′0′ 𝑟𝑒𝑡𝑢𝑟𝑛 𝑖; 𝑖𝑓 𝑠𝑡𝑟[𝑖] == ′𝑈′ 𝑟𝑒𝑡𝑢𝑟𝑛 𝑠𝑒𝑎𝑟𝑐ℎ( 𝑠𝑡𝑟, 𝑖 + 1); 𝑖𝑓 𝑠𝑡𝑟[𝑖] ! = ′𝑈′ Q) write C program to calculate lengthof the string usingRecursion 𝑙𝑒𝑛(𝑠𝑡𝑟) = { 0 𝑖𝑓 𝑠𝑡𝑟[0] == ′0′ 𝑛 1 + len(string left after removing first character) 𝑖𝑓 𝑠𝑡𝑟[0] ! = ′0′ Explanationwithexample: lengthof string“abc” = 1+ lengthof string“bc” lengthof string“bc” = 1+ lengthof string“c” lengthof string“c” = 1+ lengthof string“0” lengthof string“0” = 0 Q) Write a program in C to count numberof divisorsof a givennumberusing recursion 𝑐𝑜𝑢𝑛𝑡(𝑛, 𝑖) = { 𝑟𝑒𝑡𝑢𝑟𝑛 1; 𝑖𝑓 𝑖 == 𝑛 𝑟𝑒𝑡𝑢𝑟𝑛 1 + 𝑐𝑜𝑢𝑛𝑡( 𝑛, 𝑖 + 1) ; 𝑖𝑓 (𝑛%𝑖 == 0) 𝑟𝑒𝑡𝑢𝑟𝑛 𝑐𝑜𝑢𝑛𝑡( 𝑛, 𝑖 + 1); 𝑖𝑓(𝑛%𝑖 ! = 1) Using loops: for(i=1;i<=n;i++) { If(n%i ==0) { count=count+1; } }
  • 4.
    Recursive programtocheck whetheragivennumberisprimeorcomposite. #include <stdio.h> intcount(intn,inti) { if(i == n) return1; else if(n%i==0) return1+count(n,i+1); //1+count of divisorsfromi+1 to n if i isdivisor else if(n%i!=0) returncount(n,i+1); // count of divisorswontchange if i isnot divisor } intmain() { int n; printf("enteranumber"); scanf("%d",&n); int c=count(n,1);//count of divisorsfrom1 to n if(c== 2) printf("prime"); else printf("composite"); } Q. C program to displays integers100 through 1 usingRecursion and Iteration 𝑑𝑖𝑠𝑝𝑙𝑎𝑦(𝑛) = { 𝑝𝑟𝑖𝑛𝑡𝑓(%d, 𝑛); 𝑖𝑓 𝑛 == 1 𝑛 𝑝𝑟𝑖𝑛𝑡𝑓(%d, 𝑛); 𝑑𝑖𝑠𝑝𝑙𝑎𝑦( 𝑛 − 1); 𝑖𝑓 𝑛 > 1 Q. Write a program in C to converta decimal number to binary usingrecursion. Sample Input : 66 Sample Output: 1000010 𝑑𝑒𝑐𝑡𝑜𝑏𝑖𝑛(𝑛) = { 𝑝𝑟𝑖𝑛𝑡𝑓("%d", 𝑛%2); 𝑖𝑓 𝑛 ≤ 2 𝑛 𝑑𝑒𝑐𝑡𝑜𝑏𝑖𝑛( 𝑛/2); 𝑝𝑟𝑖𝑛𝑡𝑓("%d", 𝑛%2); 𝑖𝑓 𝑛 > 2 Full program #include <stdio.h> intdectobin(intn) { if(n<= 2) printf("%d",n%2); else { dectobin(n/2); printf("%d",n%2); } } intmain() { int n; printf("enteranumber"); scanf("%d",&n); dectobin(n); }
  • 5.
    RecursionStackof factorial of3 intfactorial(1) { if(1== 0 || 1==1) return1; else if(n>1) returnn*factorial(n-1); } intfactorial(2) { if(2== 0 || 2 ==1) return1; else if(2>1) return2*factorial(2-1); } intfactorial(3) { if(3== 0 || 3==1) return1; else if(3>1) return3*factorial(3-1); } intmain() { int n,fact; printf("enteranumber"); scanf("%d",&n); fact=factorial(n);//factorial(3) printf("factorialof %dis%d",n,fact); }
  • 6.
    Recursionstackof 4 thterm of Fibonacci intfib(2) { if( 2 == 1) return0; else if(2== 2) return1; else returnfib(n -1)+fib(n-2); } intfib(1) { if( n == 1) return0; else if(n==2) return1; else returnfib(n -1)+fib(n-2);} intfib(2) { if( 2 == 1) return0; else if(2== 2) return1; else returnfib(n -1)+fib(n-2); } intfib(3) { if( 3 == 1) return0; else if(3== 2) return1; else returnfib(3-1)+fib(3-2); } intfib(4) { if( 4 == 1) return0; else if(4== 2) return1; else returnfib(4-1)+fib(4-2); } intmain() { int n,term; printf("entern value"); scanf("%d",&n); term=fib(n); //fib(4) printf("%dthtermis%d",n,term); }
  • 7.
    C program tofindfactorial of number usingrecursion as well as iteration , Calculate power of a number program in c usingRecursion and Iteration,Write a C program to count digitsof a numberusing Recursionand Iteration, Write a C program to find sum of firstn natural numbers usingRecursion, C program to printsum of digits ofa givennumber using recursion,Write a C program to findnth term in Fibonacci SeriesusingRecursion, C program to findout the GCD (GreatestCommonDivisor )ofthe two numbersusing recursion, Write a C program to find the first upper case letterin the givenstring using recursion, write C program to calculate lengthof the string using Recursion, Write a program in C to count number of divisorsof a givennumber usingrecursion, Recursive program to checkwhetheragivennumberisprime orcomposite, C program to displaysintegers100 through 1 using Recursionand Iteration,Write a program in C to convert a decimal numberto binary usingrecursion, RecursionStackof factorial of 3 Recursionstackof 4th term of Fibonacci