2000320130071 Date
Function and Recursion
1 Write a program to print area of rectangle using & return the vlue to main
function.
#include<stdio.h>
int area(int a,int b
return a*b;
void main()
{ int a,b;
printf("Enter the dimensions of Rectangle\n");
printf("Enter the length and breadth\n");
scanf("%d%d",&a,&b);
area(a,b);
printf("Area = %d",area(a,b));
2. Write a program to print the Fibonacci series using recusion.
#include<stdio.h>
int fab_rec(int n)
{ if(n==1 || n==2)
{ return n-1;
} else
return fab_rec(n-1) + fab_rec(n-2);
}}
void main()
{ int n,c;
printf("Enter the number\n");
scanf("%d",&n);
c=(fab_rec(n-1) + fab_rec(n-2));
printf("The fibonacci series of %d is %d\n",n,c);