0

How to get largest of five numbers using arrays

28th Dec 2018, 7:53 AM
Sada Ullah
Sada Ullah - avatar
3 odpowiedzi
+ 4
int nums[5] = {2,5,7,3,4}; int l = nums[0]; for(int x=1; x<5; x++) if(nums[x] > l) l = nums[x]; cout << l;
28th Dec 2018, 11:01 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 5
Add the language tag to your post. C++, Py, ..
28th Dec 2018, 9:14 AM
Babak
Babak - avatar
+ 1
Sort an array and then take five last (or first, depends on sorting) values.
28th Dec 2018, 9:42 AM
Michal
Michal - avatar