Kindly help me to find the largest number among four numbers by conditional loop "?" .Fast. | Sololearn: Learn to code for FREE!

+1

Kindly help me to find the largest number among four numbers by conditional loop "?" .Fast.

java only

9/23/2017 5:38:22 PM

ManeeTheBeast

5 Answers

New Answer

+3

This is a conditional loop. Which loop structure are you wanting? for foreach/for in while do while be more specific all of the above take a condition and are conditional loops.

+2

public class Program { public static void main(String[] args) { int[] nums = { 234, 823, 492, 196}; int largest = 0; for(int i = 0; i < nums.length; ++i) { if ( nums[i] > largest) largest = nums[i]; } System.out.println(largest); } }

+1

i am asking by conditional loop"?"

+1

i need it.

+1

Pick one: public class Program { public static void main(String[] args) { int[] nums = { 234, 823, 492, 196}; int largest = 0; for(int i = 0; i < nums.length; ++i) { largest = nums[i] > largest ? nums[i] : largest; } System.out.println(largest); largest = 0; int j = 0; while (j < nums.length) { largest = nums[j] > largest ? nums[j] : largest; j++; } System.out.println(largest); largest = 0; for(int num: nums) { largest = num > largest ? num : largest; } System.out.println(largest); } }