How to find large and small number in c array?

Below code will help you to program for finding large and small number in array.

#include<stdio.h>
#include<conio.h>
void main ()
{
int a[2][2],i,j,larg=0,small=0;
clrscr();
printf(“Enter number for matrix\n”);
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
scanf(“%d”,&a[i][j]);
}
}
larg=a[0][0];
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
if(larg<a[i][j])
larg=a[i][j];
}
}
printf(“Large Value is%d\n”,larg);
small=a[0][0];
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
if(small>a[i][j])
{
small=a[i][j];
}
}
}
printf(“Your small value is %d\n”,small);
getch();
}

After Running program 🙂 

Leave a Reply