Q:
PHP find output programs (User-defined 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 generate syntax error because power() is not a built-in function.
Answer 2:
Output:
Explanation:
In the above program, we created a variable $NUM, which is initialized with the below expression.
$NUM = pow(5,0)*pow(5,1); $NUM = 1*5; $NUM = 5;
Now coming to the definition of function fun(). Here we pass value 5. In the body of function fun(), we declared a local variable $F with initial value 1. Here the value of $i is initialized with 5 and the loop will execute the value $i is greater than 1.
Now look,
$i = 5, $F = 1 and condition is true $F = $F * $i; $F = 5 * 1; $F = 5; After decrement of $i value. $i = 4, $F = 5 and condition is true $F = $F * $i; $F = 5 * 4; $F = 20; After decrement of $i value. $i = 3, $F = 20 and condition is true $F = $F * $i; $F = 20 * 3; $F = 60; After decrement of $i value. $i = 2, $F = 60 and condition is true $F = $F * $i; $F = 60 * 2; $F = 120; After decrement of $i value. $I=1 then condition get false and loop will terminate.
Answer 3:
Output:
Explanation:
In the above program, we created a variable $NUM, which is initialized with the below expression.
$NUM = pow(5,0)*pow(5,1); $NUM = 1*5; $NUM = 5;
Now coming to the definition of function fun(). Here we pass value 5. In the body of function fun(), Here value of $i is initialized with 1, and the loop will execute the value $i is less than equal to 1.
Then the loop will print the table of 5, in every iteration value of $i will multiply with 5 and print the table on the webpage.
Answer 4:
Output:
Explanation:
In the above program, we created an array that contains values "RED", "GREEN", "BLUE". Here, we pass the array into user define function fun(), and in the function body, we accessed elements of the array using a foreach loop and print them on the webpage.
Answer 5:
Output:
Explanation:
The above program will print 65 on the web page. In the above program, we created an array that contains integer numbers, and we created a user-define function with array as an argument.
In the function body, we created a local variable $VAR initialized with the first element of the array. Then we access the elements of the array one by one using the foreach loop. Here, $VAR is compared with each element of the array, if $VAR is less than a specified element swap, then we copied the large value to the $VAR. At the end, $VAR will contain the largest element of the array.
Then 65 will be printed on the webpage.
need an explanation for this answer? contact us directly to get an explanation for this answer