Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering Languages Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# MindQ

Ragu Sivaraman
Ranch Hand
Posts: 464
17. If arr[] contains only positive integer values, what does this function do?
public int guessWhat( int arr[] )
{ int x= 0;
for( int i = 0; i < arr.length; i++ )
x = x < arr[i] ? arr[i] : x;
return x;
}
a) Returns the index of the highest element in the array
b) Returns true/false if there are any elements that repeat in the array
c) Returns how many even numbers are in the array
d) Returns the highest element in the array
e) Returns the number of question marks in the array

Can some explain it to me?

shrirang
Greenhorn
Posts: 3
the logic is nothing but the logic of finding highest number in the array.Only thing is that its conditional operator that is used.

Roopa Bagur
Ranch Hand
Posts: 267
d.returns the highest element in the array.
Originally posted by Ragu Sivaraman:
17. If arr[] contains only positive integer values, what does this function do?
public int guessWhat( int arr[] )
{ int x= 0;
for( int i = 0; i < arr.length; i++ )
x = x < arr[i] ? arr[i] : x;
return x;
}
a) Returns the index of the highest element in the array
b) Returns true/false if there are any elements that repeat in the array
c) Returns how many even numbers are in the array
d) Returns the highest element in the array
e) Returns the number of question marks in the array

Can some explain it to me?

Ragu Sivaraman
Ranch Hand
Posts: 464
Yup got it
Thankx guys