2.3 find the minimum no. from array using recursion.
#include<stdio.h>
int maxim(int a[]);
int n;
void main()
{
int i,a[20];
clrscr();
printf("Enter the range :");
scanf("%d",&n);
printf("Enter the element of array:\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("The Minimum no. is :%d",maxim(a));
getch();
}
int maxim(int a[])
{
static int i=0,min=1999;
if(i<n)
{ //min=a[0];
if(min>a[i])
{
min=a[i];
}
i++;
maxim(a);
}
return min;
}
#include<stdio.h>
int maxim(int a[]);
int n;
void main()
{
int i,a[20];
clrscr();
printf("Enter the range :");
scanf("%d",&n);
printf("Enter the element of array:\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("The Minimum no. is :%d",maxim(a));
getch();
}
int maxim(int a[])
{
static int i=0,min=1999;
if(i<n)
{ //min=a[0];
if(min>a[i])
{
min=a[i];
}
i++;
maxim(a);
}
return min;
}
Comments
Post a Comment