PHP Math Functions Aptitude Questions and Answers

PHP Math Functions Aptitude: This section contains aptitude questions and answers on PHP Math Functions.
Submitted by Nidhi, on March 14, 2021

This section contains Aptitude Questions and Answers on PHP Math Functions.

1) What is the correct output of the given code snippets?
```<?php
\$num1 = - 10;
\$num2 = - 20;

\$num3 = abs(\$num1 - \$num2);

echo (\$num3);
?>
```

2) What is the correct output of the given code snippets?
```<?php
\$r = 5;
\$area = PY() * \$r * \$r;
echo (\$area);
?>
```

3) Which of the following function is used to convert degree to radian in PHP?

4) Which of the following function is used to convert radian to the degree in PHP?

5) What is the correct output of the given code snippets?
```<?php
\$A = 11.2;
\$B = 3;

\$rem = \$A % \$B;
echo (\$rem);
?>
```

6) What is the correct output of the given code snippets?
```<?php
\$A = 11.2;
\$B = 3;

\$rem = modf(\$A, \$B);
echo (\$rem);
?>
```

7) What is the correct output of the given code snippets?
```<?php
\$A = 11.2;
\$B = 3;

\$rem = fmod(\$A, \$B);

echo (\$rem);
?>
```

8) What is the correct output of the given code snippets?
```<?php
\$num = - 7.8;
echo (floor(\$num));
?>
```

9) What is the correct output of the given code snippets?
```<?php
\$num = 0.70;
echo (ciel(\$num));
?>
```

10) What is the correct output of the given code snippets?
```<?php
\$num = 0.70;
echo (ceil(\$num));
?>
```

11) Which of the following constants are used in round() function in PHP?
1. PHP_ROUND_HALF_UP
2. PHP_ROUND_HALF_DOWN
3. PHP_ROUND_HALF_EVEN
4. PHP_ROUND_HALF_ODD

Options:

12) What is the correct output of the given code snippets in PHP?
```<?php
echo (round(3.456789, 2));
?>
```

13) What is the correct output of the given code snippets?
```<?php
echo (round(12345678, -2));
?>
```

14) What is the correct output of the given code snippets?
```<?php
echo (round(12.5, 0, PHP_ROUND_HALF_UP));
?>
```

15) What is the correct output of the given code snippets?
```<?php
echo (round(12.5, 0, PHP_ROUND_HALF_ODD));
?>
```

16) Which of the following function is used to calculate the power of a number?

17) Which of the following function is used to calculate the square root of a number?

18) Which of the following function is used to get the natural logarithm of a number based on a specified base?

19) Which of the following functions are used for logarithm in PHP?
1. log()
2. log10()
3. log1p()
4. log1q()

Options:

20) What is the correct output of the given code snippets in PHP?
```<?php
\$NUM = max(1, 2, 8, 5, 6);
echo \$NUM;
?>
```

21) What is the correct output of the given code snippets?
```<?php
\$NUM = max(array(
1,
2,
8,
5,
6
));
echo \$NUM;
?>
```

22) What is the correct output of the given code snippets?
```<?php
\$NUM = max("1,2,8,5,6");
echo \$NUM;
?>
```

23) Which of the following functions are used to generate random numbers in PHP?
1. rand()
2. getrandmax()
3. mt_rand()
4. xt_rand()

Options:

24) What is the correct output of the given code snippets in PHP?
```<?php
\$NUM = rand(10, 20);
echo \$NUM;
?>
```

25) What is the correct output of the given code snippets?
```<?php
\$NUM = rand();
echo \$NUM;
?>
```

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.