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
Answer1:
Output:
Explanation:
In the above program situation of the infinite loop will occur because here we did not put any condition for the loop. If we did not mention the loop condition then the loop will condition is always true, and the loop will never terminate.
Answer2:
Output:
Explanation:
The above program will print "16" on the webpage. In the above program, we created $RES initialized with 1. Here, we used counter variable $I, which is initialized with 1.
Here, we did not put any condition for the loop. If we did not mention the loop condition then the loop will condition is always true. But for loop termination, we used if condition and loop will terminate using the break statement.
$I=1, $RES=1 and IF condition will true $RES = $RES + $I; $RES = 1 + 1; $RES = 2; $I=2, $RES=2 and IF condition will true $RES = $RES + $I; $RES = 2 + 2; $RES = 4; $I=3, $RES=4 and IF condition will true $RES = $RES + $I; $RES = 4 + 3; $RES = 7; $I=4, $RES=7 and IF condition will true $RES = $RES + $I; $RES = 7 + 4; $RES = 11; $I=5, $RES=11 and IF condition will true $RES = $RES + $I; $RES = 11 + 5; $RES = 16;
$I=6, $RES=16 condition will false and 16 will print on the webpage.
Answer3:
Output:
Explanation:
In the above program situation of the infinite loop will occur because we used semicolon at the end of the loop. Then the value of $RES will not increase and the loop condition will never false.
Answer4:
Output:
Explanation:
In the above program, we created $RES and initialized it with 1. And we used the below expression in place of loop condition.
((int)(pi()))
This expression will return 3 for the loop condition.
$I=1, $RES=1 and condition will true $RES = $RES + $I; $RES = 1 + 1; $RES = 2; $I=2, $RES=2 and condition will true $RES = $RES + $I; $RES = 2 + 2; $RES = 4; $I=3, $RES=4 then the condition will false.
Answet 5:
Output:
Explanation:
In the above program, we declared a variable $VAR and $I that are initialized with "HELLO" and 0 respectively. Here, we used "do …while" loop and access characters one by one form the string "HELLO" and print them on the webpage until $I becomes 5.
need an explanation for this answer? contact us directly to get an explanation for this answer