Output Questions for Class 10 ICSE Computer Applications
Give the output of the following program segment:
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);
Java
Java Arrays
22 Likes
Answer
a=49.0
b=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
Answered By
10 Likes