Writing Java Expression – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  

Login
[lwa]



Exam Questions-ICSE2015-03I #JAVA#4279    siteicon   siteicon  

Problem Statement - Writing Java Expression

Write the Java expression for: a2+b2/2ab

Solution

TC++ #4279

Java expression for: a2+b2/2ab  would be –

(Math.pow(a,2)+Math.pow(b,2)) / (2*a*b)

Notes

  • The same expression can also be written as
    (a*a+b*b) / (2*a*b)

Common Errors

  • This expression needs appropriate use of brackets as shown in numerator and denominator for correct evaluation.


Share

sunmitra| Created: 6-Apr-2018 | Updated: 16-Apr-2019|ICSE2015






Back