Write a program to find the largest value from the given array 2D using user defined function

//this is a program to find the largest value from  the given array(2X2) using user defined function
#include<stdio.h>
#include<conio.h>
int largest();
void main()
{
int x;

x=largest();

printf("\n\nThe larges value is %d",x);
getch();
}
int largest()
{
int a[2][2],i,j,large=0;

printf("\n\nEnter the values of array: ");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("\n\nEnter any number: ");
scanf("%d",&a[i][j]);
}

}

large=a[0][0];
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
if(large<a[i][j])
large=a[i][j];
}
}
return large;
}

Previous
Next Post »