import
java.util.Scanner;
class group{
public static void main(String argn[]){
Scanner data = new Scanner(System.in);
int num, i, temp, max;
// Reading numbers want to be read
System.out.print("Enter number you want to enter:");
num = data.nextInt();
System.out.println("Enter " +num+ " number");
// Reading 1st number
max = data.nextInt();
// Reading other number
for (i=1; i < num; i++) { temp = data.nextInt();
if(temp < max)
continue;
else
// largest number
max = temp;
}
System.out.println("Largest Number is "+max);
}
}
Output:-
Enter number you want to enter:
10
Enter 10 number
248
445852
248
215
25854
2145
11458
21145
115
115585
Largest Number is 445852
class group{
public static void main(String argn[]){
Scanner data = new Scanner(System.in);
int num, i, temp, max;
// Reading numbers want to be read
System.out.print("Enter number you want to enter:");
num = data.nextInt();
System.out.println("Enter " +num+ " number");
// Reading 1st number
max = data.nextInt();
// Reading other number
for (i=1; i < num; i++) { temp = data.nextInt();
if(temp < max)
continue;
else
// largest number
max = temp;
}
System.out.println("Largest Number is "+max);
}
}
Output:-
Enter number you want to enter:
10
Enter 10 number
248
445852
248
215
25854
2145
11458
21145
115
115585
Largest Number is 445852
0 comments:
Post a Comment