Sam executes the following program segment and the answer displayed is zero irrespective of any non zero values are given. Name the error. How the program can be modified to get the correct answer?
void triangle(double b, double h)
{
double a;
a = ½ * b * h;
System.out.println(“Area=”+a);
}


Solution



logical error
void triangle(double b, double h)
{
double a;
a = 0.5 * b * h;
System.out.println(“Area=”+a);
}


Contact Us

REACH US

SERVICES

  • CODING
  • ON-LINE PREPARATION
  • JAVA & PYTHON

ADDRESS

B-54, Krishna Bhawan, Parag Narain Road, Near Butler Palace Colony Lucknow
Contact:+ 919839520987
Email:info@alexsir.com