Array-promo
Matrix-promo

Question

program to Largest element in boundary elements of matrix

Matrix  = [9, 8, 7]
          [6, 5, 4]
          [3, 2, 1]

LARGEST ELEMENT IN BOUNDARY ELEMENT OF MATRIX:9

Share code with your friends

Share on whatsapp
Share on facebook
Share on twitter
Share on telegram

Code

import java.util.Scanner;
public class largestBoundaryElementsOfMatrix
{
    public static void main(String[] args)
    {
        int row=0,col=0,i=0,j=0,max=0;
        int a[][];


        Scanner sc=new Scanner(System.in);
        System.out.println("ENTER THE NUMBER OF ROW OF MATRIX");
        row=sc.nextInt();
        System.out.println("ENTER THE NUMBER OF COLUMN OF MATRIX");
        col=sc.nextInt();

        a=new int[row][col];
        System.out.println("ENTER THE ELEMENTS IN MATRIX");
        for(i=0;i< row;i++)
        {
            for(j=0;j< col;j++)
            {
                a[i][j]=sc.nextInt();
            }
        }
        System.out.println("MATRIX:");
        for(i=0;i< row;i++)
        {
            for(j=0;j< col;j++)
            {
                System.out.print(a[i][j]+" ");
            }
            System.out.println();
        }
        max=a[0][0];


        for(i=0;i< row;i++)
        {
            for(j=0;j< col;j++)
            {

                if(i==0 ||j==0||i==(row-1)||j==(col-1))
                {
                    if(a[i][j]> max)
                    {
                        max=a[i][j];
                    }
                }
            }
        }
        System.out.println("LARGEST BOUNDARY ELEMENT IN MATRIX:"+max);
    }
}

Coding Store

Sale

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹250.Current price is: ₹150.
Sale

Original price was: ₹350.Current price is: ₹200.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale
Mastering Array

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹250.Current price is: ₹150.
Sale

Original price was: ₹350.Current price is: ₹200.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale
Mastering Array

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹250.Current price is: ₹150.
Sale

Original price was: ₹350.Current price is: ₹200.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale
Mastering Array

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹80.Current price is: ₹50.
Sale

Original price was: ₹80.Current price is: ₹50.

Leave a Reply

Your email address will not be published. Required fields are marked *