Monday 23 February 2015

Find the Index of largest Number in Array in Java

Structure of the Problem Requirements 

This Program will return the index of the largest number in Array in Java Program. There is a simple logic for this and here is the complete code of this program. To get the same program code in C++ click here.

Source Code

import java.util.Scanner;
public class Arrayindex {


public static void main(String[] args) {
System.out.println("\t\t\t LEP Tutorials");
Scanner input = new Scanner (System.in);
int [] num = new int [5];
int a=0, index =0;
for (int i =0;i<5;i++)
{
System.out.print("Enter Your Number :");
num[i] = input.nextInt();
}
for (int i =0;i<5;i++)
{
if (num[i] >a)
{
a =num [i];
index = i;
}
}
System.out.println("The largest Number is the Array is :" + index);
}
}

Output of the Program

Find the Index of largest Number in Array in Java


Share it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

1 comments: Post Yours! Read Comment Policy!▼
Important Note:
We have Zero Tolerance to Spam. Chessy Comments and Comments with Links will be deleted immediately upon our review.