Computer Science, asked by bishtdinesh026, 1 year ago

Write a program to pick up the largest number from any 5 row by 5 column matrix.

Answers

Answered by vershamishra12oycd27
7
#include<stdio.h>
#include<conio.h>
void main() 
{

int i,j,a[5][5];
clrscr();

printf("\nEnter the numbers into matrix:\n");
for(i=0;i<5;i++) 
{
    for(j=0;j<5;j++) 
   {
       scanf("%d",&a[i][j]);
   }
}


printf("matrix you entered is:\n\n");
for(i=0;i<5;i++) 
{
    for(j=0;j<5;j++) 
   {
        printf(" %d ",a[i][j]);
   }
printf("\n");
}

/* finding the largest number */
int max=a[0][0];
for(i=0;i<5;i++)
{
     for(j=0;j<5;j++) 
     {
           if(max<a[i][j])      /* if number is larger than first element */
                max=a[i][j];          /* larger number is placed as the first element */
     }
}
printf("\nThe largest number in matrix is: %d",max);
getch();
}
Answered by siddhartharao77
4
#include<stdio.h>

main(){ int arr[5][5];

 int i,j,k;

 for(i=0;i<=4;i++)

 {

  printf("\n");

  for(j=0;j<=4;j++)

  {

   printf("Enter the number : ");

   scanf("%d",&arr[i][j]);

  }

 }

 for(i=0;i<=4;i++)

 {

  printf("\n");

  for(j=0;j<=4;j++)

  {

   if(arr[i][j]>arr[i][j-1])

    k=arr[i][j];

    arr[i][j]=k;

  }

 }

printf("The Largest number in the 5*5 matrix is :  %d",k);

getch();

}.


Hope this helps!
Similar questions