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









Related Tutorials/Questions & Answers:
Advertisements