If int x [] = {2, 5, 6, 8, 10); what are the values of p and q?
(i) p = length;
(ii) q =Math.sqrt(x [1] + x [4]) * x [0]);
help please!!!!
Answers
Answered by
4
Correct Question:
If int x [] = {2, 5, 6, 8, 10}; what are the values of p and q?
(i) p = x.length;
(ii) q =Math.sqrt(x[1] + (x [4] * x [0]));
Answer:
p = 5
q = 5.0
Explanation:
x.length returns the length of the array x[]. Length of array is - 5. So, p = 5.
q = Math.sqrt(x[1]+(x[4] * x[0]))
= Math.sqrt(5+(10 × 2))
= Math.sqrt(5 + 20)
= Math.sqrt(25)
= 5.0
So, p = 5 and q = 5.0.
•••♪
Answered by
3
Correct Question:-
- If int x[]= {2, 5, 6, 8, 10}; what are the values of p and q?
(i) p = x.length;
(ii) q = Math.sqrt(x[1] + x[4]) * x [0]);
Required Answer:-
(i)
p=x.length;
//x.length will return the length of the array 'x' i.e. no. of elements in array 'x'
•°• p= 5
(ii)
q = Math.sqrt(x[1] + x[4]) * x[0]);
//Math.sqrt() returns the Square Root of a number. It returns in double data type.
So,
Math.sqrt(x[1] + x[4]) * x[0])
>>Math.sqrt(5+10*2)
>>Math.sqrt(5+20)
>>Math.sqrt(25)
>>5.0
•°• q=5.0
Correct Answer:-
- p=5
- q=5.0
Note
- Index numbers always starts with zero(0).
Similar questions