Home Answers Viewqa Java-Interview-Questions how to find largest number?

 
 


rayda
how to find largest number?
3 Answer(s)      4 years and 4 months ago
Posted in : Java Interview Questions

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









Related Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.