Computer Science, asked by mayankjoshiold5, 5 months ago

What will be the final values stored in variables when executed?

double a = -99.51;

double b = -56.25;

i) double p = Math.abs(Math.floor(a));

ii) double q = Math.sqrt(Math.abs(b));​

Answers

Answered by BrainlyProgrammer
1

Question:-

  • What will be the final value of a and b :-

double a= -99.51;

doubt b= -56.25;

I) double p = Math.abs(Math.floor(a));

II) double q = Math.sqrt(Math.abs(b));

Answer:-

I) 100.0

Explaination:-

  • Math.abs(Math.floor(-99.51)
  • Math.floor() rounds off the number to the next lower integer i.e. Here it will return -100.0. (Note: Math.floor() always returns double data type value.)
  • Math.abs() will return the absolute value of the number i.e. Here it will return 100.0

II) 7.5

Explanation:-

  • Math.sqrt(Math.abs(-56.25))
  • Math.abs() will return absolute value of the number i.e. Here it will return 56.25
  • Now, Math.sqrt() returns square root of the positive number (as square root of negative number is not possible) so here it will return the square root of 56.25 which is 7.5

Learn More about Maths Function-

  • Math.max() is used to find the maximum value between 2 numbers. SYNTAX:- Math.max(a,b);
  • Math.min() returns the minimum value between two numbers. SYNTAX:- Math.min(x,y);
  • Math.abs() returns absolute value of the given number. SYNTAX:- Math.abs(a);
  • Math.ceil() returns rounded value upto nearest higher integer. SYNTAX:- Math.ceil(x);
  • Math.floor() returns rounded value upto nearest lower integer. SYNTAX;- Math.floor(x);
  • Math.round() returns the rounded value of the number upto nearest integer. SYNTAX:- Math.round(x);
  • Math.cbrt() returns cube root of a number. SYNTAX:- Math.cbrt(x);
  • Math.sqrt() returns square root of a positive real number. SYNTAX:- Math.sqrt(x);

mayankjoshiold5: thx bro
Similar questions