Let Us C (Chapter 8 : Arrays) : Program-10
(j) Write a program to pick up the largest number from any 5 row by 5 column matrix.
// Let Us C (Chapter 8 : Arrays) : Program-10
/* Write a program to pick up the largest number from any 5 row by 5 column matrix */
#include<stdio.h>
long int Arr[5][5],Largest;
unsigned Write a program to pick up the largest number from any 5 row by 5 column matrix. i,j;
void main()
{
clrscr();
printf("Enter 25 elements of 5x5 matrix\n");
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
printf("Enter [%d][%d]th element: ",i,j);
scanf("%ld",&Arr[i][j]);
}
}
Largest = Arr[0][0];
printf("\nEntered Matrix is : \n");
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
printf("%8ld ",Arr[i][j]);
if(Largest < Arr[i][j])
Largest = Arr[i][j];
}
printf("\n");
}
printf("\nLargest element is : %ld",Largest);
}
OUTPUT
Comments
Post a Comment