Java
Programming and Technical
Programming
Program
What is the output of this program?
class average {
public static void main(String args[])
{
double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5};
double result;
result = 0;
for (int i = 0; i < 6; ++i)
result = result + num[i];
System.out.print(result/6);
}
}
a) 16.34
b) 16.566666644
c) 16.46666666666667
d) 16.46666666666666
Read Solution (Total 18)
-
- c) 16.46666666666667
because double will precise the result hence untill it find a change in the value after decimal such as in above example 6 is coming again and again so untill it find out a change it will print out the value that is why option (D) is not an answer - 10 years agoHelpfull: Yes(16) No(0)
- c is the answer.....
- 10 years agoHelpfull: Yes(1) No(1)
- 16.46666666666667
- 10 years agoHelpfull: Yes(1) No(0)
- Since it is double....the answer will be option d
- 10 years agoHelpfull: Yes(0) No(3)
- ans:c because in java double print after decimal it will find 0
- 10 years agoHelpfull: Yes(0) No(1)
- correct ans : c
- 10 years agoHelpfull: Yes(0) No(1)
- ans is c since the ans is stored in double type of variable
- 9 years agoHelpfull: Yes(0) No(1)
- c is correct option
- 9 years agoHelpfull: Yes(0) No(0)
- 16.46666666666667
option c
- 9 years agoHelpfull: Yes(0) No(0)
- c)
98.8/6=16.46666666666667 - 8 years agoHelpfull: Yes(0) No(0)
- d is correct
- 8 years agoHelpfull: Yes(0) No(1)
- Answer is c
- 6 years agoHelpfull: Yes(0) No(0)
- c) 16.46666666666667 is the correct answer by adding all the num[i] from values 0 to 5 and by adding to result it gives the ans.
- 6 years agoHelpfull: Yes(0) No(0)
- answer : C
- 5 years agoHelpfull: Yes(0) No(0)
- a 16.4
5.5+10.1+11+12.8+56.9+2.5/6 - 5 years agoHelpfull: Yes(0) No(0)
- c is correct ans
- 5 years agoHelpfull: Yes(0) No(0)
- Option C is correct
- 3 years agoHelpfull: Yes(0) No(0)
- C is the answer.
- 1 year agoHelpfull: Yes(0) No(0)
Java Other Question