Find the largest number | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Find the largest number

1,5,10

12th Aug 2017, 8:40 AM
shijin
2 Answers
+ 8
10, in java : int a=0; int[] largest={1,5,10}; for(int x:largest){ if(x>a) a=x; } System.out.println(a); if you are using c++ you only change array declaration and for loop.:/ https://code.sololearn.com/cXjCK4ZOwBG1/?ref=app this is c++ code https://code.sololearn.com/cC285GI41ega/?ref=app
12th Aug 2017, 9:29 AM
Nithiwat
Nithiwat - avatar
+ 3
Java: System.out.print(Arrays.stream(new int[]{1, 5, 10}).max().getAsInt()); Output -> 10
12th Aug 2017, 2:21 PM
Garikai
Garikai - avatar