Advertisements
Advertisements
प्रश्न
John was asked to write a Java code to calculate the surface area of a cone, the following code was written by him:
Surface area of cone is A = πrl `l = sqrt(r^2 + h^2)`
class area
{ double area (double r, double h)
{ double l, a;
a=22.0/7*r*l;
l=Math.sqrt(r*r+h*h);
return a;
}
}
Specify the type of the error in the above program, correct and write the program to be error free.
कोड लेखन
Advertisements
उत्तर
Logical Error: Area has been calculated before calculation of 1.
class area
{
double area(double r, double h)
{
I=Math.sqrt(r*r + h*h)
a=22.0/7*+*1;
return a;
}
}shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2024-2025 (March) Official Board
