Find Maximum number from 1-D Array

Why we have to understand array?

Answer: Logic of array

Why array is most important?

Answer: Structure and Simplicity

 

This is one small list of use of arrays in programming language. We can use arrays in our every steps of advance java.

 

In this blog, we work on array basic to advance level example. And also provide some tutorial on it.

 

How to find maximum number from 5 Numbers?

class arr2

{

            public static void main(String args[])

            {

                        int[] x = new int[5];            // Dec of array

                        x[0] = 23;

                        x[1] = 34;

                        x[2] = -7;

                        x[3] = 54;

                        x[4] = 12;

 

                        int max=0;

                        for(int i=0;i<x.length;i++)

                        {

                                    if(x[i] > max)                        // Check maximum number

                                    {

                                                max = x[i];    // assign maximum number to max var.

                                    }          

                        }

 

                        System.out.println(“Max = ” + max);

            }

}

 

Output:

 

Max = 54

 

 

Basic To Advance Level Tutorial.

 

NoTitle
1Find minimum number from 10 numbers.
2Find sum and average of even value from give 10 numbers
3Find count number of prime numbers from given 10 numbers
4Enter Number :  [Find binary number of that number]
5Enter Number : [Find octal number of that number]
6Enter 10 numbers in one arrays X[10] , then find even and odd number from arrays and store in different two arrays.

Example X[10] -> numbers

Find Even and Odd

Store In

Odd[]

Even[] Array.

 

 

 

If you found any query on this blog, you can directly comment on this blog post.

 

How to Earn money Online

 

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

177total visits,6visits today


mayank

Hello, I am Maddy a Java blogger, trainer and developer

Related articles

Leave a Reply

EmailEmail
PrintPrint