how to find largest number?

Ads
 

how to find largest number?

View Answers

January 29, 2009 at 10:43 PM

Hi

Can u please clarify your query, You want to find the greater number which user enter on the console?

Thanks...

January 29, 2009 at 11:13 PM

class Numbers{
public static void main(String args[]){
int i, max, min;
int no[] = {5,78,1,6,74,9,6,4,6,7};
System.out.println("\nElements in the Array: \n");

for(i=0; i < 10; i++){
System.out.print(no[i]+"\t");
}

System.out.println("\n");
max = no[0];
min = no[0];

for(i=1; i < 10; i++){
if(max < no[i]){
max = no[i];
}else if(min > no[i]){
min = no[i];
}
}
System.out.print("\nGreatest Number: "+ max);
System.out.print("\nSmallest Number: "+ min);
}
}

January 30, 2009 at 11:49 AM

yup yup..
i want to know how to find the greatest number that enter by the user..
sorry for not stating my question more clearer..
thanks

Ads









Related Tutorials/Questions & Answers:
find largest value
generate random numbers and display the largest
Advertisements
Java Find Automorphic numbers
how to add to numbers in java
Java find prime numbers without using break statement
Java Find Median
To find first two maximum numbers in an array
How to put text file numbers to array and check the position of numbers?
How to generate a list of random numbers?
How to generate a list of random numbers?
How to generate a list of random numbers?
how to find jdk path in ubuntu?
How to find hashtable size in Java?
To find first two maximum numbers in an array,using single loop without sorting array.
To find first two maximum numbers in an array,using single loop without sorting array.
How to add two numbers in Java?
How to list even numbers between 1 and 100?
How to Find PHP version and configuration?
how I make the numbers in descending order ?
How to find a servlet object by name?
How to find maximum value in ArrayList
How to find maximum value in ArrayList
How to find maximum value in ArrayList
How to find maximum value in ArrayList
how to find which user has modified the file
How to find a config file in spring project
How to print a equilateral triangle patren with numbers
how to find the sum of integers in a string of sentence in java
How to find java jobs at any where in india
How to find latitude and longitude of my Mobile Phone?
this code gives addition of 2 numbers in j2me..but the code is not executing ..can u pls find out the error...??

Ads