Q:
PHP find output programs (Math Functions) | set 2
belongs to collection: PHP Find Output Programs
PHP Find Output Programs
- PHP find output programs (basics) | set 1
- PHP find output programs (basics) | set 2
- PHP find output programs (basics) | set 3
- PHP find output programs (Superglobals) | set 1
- PHP find output programs (conditional statements) | set 1
- PHP find output programs (conditional statements) | set 2
- PHP find output programs (conditional statements) | set 3
- PHP find output programs (switch Statement) | set 1
- PHP find output programs (switch Statement) | set 2
- PHP find output programs (switch Statement) | set 3
- PHP find output programs (Operators) | set 1
- PHP find output programs (Operators) | set 2
- PHP find output programs (Operators) | set 3
- PHP find output programs (Loops) | set 1
- PHP find output programs (Loops) | set 2
- PHP find output programs (Loops) | set 3
- PHP find output programs (Loops) | set 4
- PHP find output programs (Arrays) | set 1
- PHP find output programs (Arrays) | set 2
- PHP find output programs (Arrays) | set 3
- PHP find output programs (User-defined functions) | set 1
- PHP find output programs (User-defined functions) | set 2
- PHP find output programs (User-defined functions) | set 3
- PHP find output programs (String Functions) | set 1
- PHP find output programs (String Functions) | set 2
- PHP find output programs (Number Functions) | set 1
- PHP find output programs (Math Functions) | set 1
- PHP find output programs (Math Functions) | set 2
- PHP find output programs (Date and Time) | set 1
- PHP find output programs (define Constant) | set 1
- PHP find output programs (static variables, classes, methods) | set 1
- PHP find output programs (static variables, classes, methods) | set 2
- PHP find output programs (Regular Expressions) | set 1
- PHP find output programs (Exceptions) | set 1
- PHP find output programs (Exceptions) | set 2
- PHP find output programs (Filters) | set 1
- PHP find output programs (Filters) | set 2
- PHP find output programs (JSON) | set 1
- PHP find output programs (const Keyword) | set 1
- PHP find output programs (Class & Objects) | set 1
- PHP find output programs (Class & Objects) | set 2
- PHP find output programs (Class & Objects) | set 3
- PHP find output programs (Constructors and Destructors) | set 1
- PHP find output programs (Constructors and Destructors) | set 2
- PHP find output programs (Constructors and Destructors) | set 3
- PHP find output programs (Inheritance) | set 1
- PHP find output programs (Inheritance) | set 2
- PHP find output programs (Inheritance) | set 3
Answer 1:
Output:
Explanation:
The above program will print "8 8" on the webpage. In the above program, we created 3 variables $NUM1, $NUM2, and $NUM initialized with 2.51, 2.49, and 3.21. Here, we used built-in function round().
The round() function is used to round off the floating-point number. For example, if the number is 2.51 then it becomes 3 or if the number is 2.49 then it becomes 2.
Now we evaluate expressions one by one:
$RES1 = round($NUM1+$NUM2+$NUM3); $RES1 = round(2.51+2.49+3.21); $RES1 = round(5+3.21); $RES1 = round(8.21); $RES1 = 8;
And,
$RES2 = round($NUM1)+round($NUM2)+round($NUM3); $RES2 = round(2.51)+round(2.49)+round(3.21); $RES2 = 3 + 2 + 3; $RES2 = 8;
Then the final values of $RES1 and $RES2 will be printed on the webpage.
Answer 2:
Output:
Explanation:
The above program will generate syntax error because we used modf() function in the above code, the modf() is not a built-in function then it will generate a syntax error.
Answer 3:
Output:
Explanation:
The above code will print "0 0.6" on the webpage, we cannot get the remainder from floating-point numbers using modulus operator '%'.
To get the remainder from floating-point numbers, we need to use the built-in function fmod().
Then the final values of $NUM3 and $NUM4 will be 0 and 0.6 respectively.
Answer 4:
Output:
Explanation:
In the above program, we used variants of the round() function. The above statements will print the following output:
2.47 54000 5 5 6 9
Here, we used following predefined constants:
PHP_ROUND_HALF_UP PHP_ROUND_HALF_DOWN PHP_ROUND_HALF_EVEN PHP_ROUND_HALF_ODD
All given constants round off the specified number.
Answer 5:
Output:
Explanation:
The above program will print 180 on the webpage. In the above program, we defined a variable $num initialized with PI() value, and we used one more built-in function rad2deg(), which is used to convert the radian value to the degree.
The function rad2deg() will return 180 for PI value 3.1415926535898, and assigned to variable $deg. Finally, we print the value of $deg.
need an explanation for this answer? contact us directly to get an explanation for this answer