#include<stdio.h>
#include<conio.h>
void input();
void traverse();
int max();
int min();
int ub,lb,a[10],mx,mn;
void main()
{
clrscr();
printf("program to find out maximum and minimum of given numbers.");
printf("\n\t-------------------------OUTPUT------------------------");
input();
traverse();
mx=max();
mn=min();
printf("\nthe maximum value is->%d",mx);
printf("\nthe minimum value is->%d",mn);
getch();
}
void input()
{
int i;
printf("\n\nenter the lower and upper bound of an array");
scanf("%d%d",&lb,&ub);
if(lb>ub)
{
printf("\nthe lower bound and upper bound are not compatible");
getch();
exit(0);
}
printf("\nenter the elements in the array");
for(i=lb;i<=ub;i++)
{
scanf("%d",&a[i]);
}
}
void traverse()
{
int i;
printf("\nthe elements in the array are->");
for(i=lb;i<=ub;i++)
{
printf("\t%d",a[i]);
}
}
int max()
{
int i;
mx=a[lb];
for(i=lb+1;i<=ub;i++)
{
if(mx<a[i])
mx=a[i];
}
return(mx);
}
int min()
{
int i;
mn=a[lb];
for(i=lb+1;i<=ub;i++)
{
if(mn>a[i])
mn=a[i];
}
return(mn);
}