Forum : Not Getting Proper output
Brief description  about Online courses   join in Online courses
View Anusha  D R 's Profile

Not Getting Proper output

class Higher {
public static void main(String[] args) {


int m[]={10,60,20,50,80,40,90,70,30,100};

for(int i=0;i<9;i ){
for(int j=1;j<10;j ){
if(m[i] > m[j])
System.out.println("Number with higher value is" m[i]);
else
System.out.println("Number with higher value is" m[j]);
}
}
}
}
Asked by Anusha D R | Aug 16, 2010 |  Reply now
Replies (2)
View arun kumar das 's Profile
Hi Anusha,

I am not sure about the outcome of the program, do you want the program to compare each element with every other element and print the highest value?

I have made few changes and below program compares the first element iwth every other element and prints the result and then it will compare second element with every other element and so on:

class Higher {
public static void main(String[] args) {


int m[]={10,60,20,50,80,40,90,70,30,100};

for(int i=0;i<9;i++ ){
for(int j=1;j<10;j++ ){
if(m[i] > m[j])
System.out.println("Number with higher value is" +m[i]);
else
System.out.println("Number with higher value is" +m[j]);
}
}
}
}
Aug 17, 2010
View anusha d-r 's Profile
In the above program i have incremented i and j some error is occurred while pasting the program
Aug 16, 2010