Analyse the following program segment and determine the output; int m=144; double n=Math.sqrt(m); System.out.println(n);
Answers
Answered by
1
Answer:
Question:
Analyse the following program segment and determine the output; int m=144; double n=Math.sqrt(m); System.out.println(n);
Answer:
int n[] ={1,2,3,5,7,9,13,16};
double a=Math.pow(n[4], n[1]);
double b=Math.sqrt(n[5]+n[7]);
System.out.println("a=" + a);
System.out.println("b=" + b);
Answer
a=49.0
a=49.0b=5.0
WORKING
n[4] is 7 and n[1] is 2. Math.pow(n[4], n[1]) becomes Math.pow(7, 2) so a becomes 49.0. Next, n[5] is 9 and n[7] is 16. Math.sqrt(n[5]+n[7]) becomes Math.sqrt(9 + 16) ⇒ Math.sqrt(25) ⇒ 5.0
Similar questions