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:
The above program will print 125 on the webpage. In the above program, we created variables $NUM, $R1, and $R2 initialized with 5, 3, and 1.
Let's evaluate loop iterations:
$NUM = 5, $R1=3, $R2=1 $R2 = $R2*$NUM; $R2 = 1*4; $R2 = 5; $NUM = 5, $R1=2, $R2=5 and condition will true. $R2 = $R2*$NUM; $R2 = 5*5; $R2 = 25; $NUM = 5, $R1=1, $R2=25 and condition will true. $R2 = $R2*$NUM; $R2 = 25*5; $R2 = 125; $NUM = 5, $R1=0, $R2=25 and condition will false and loop will terminate.
Answer 2:
Output:
Explanation:
In the above program, we used nested loops. Here, we wrote a program to print the pattern of stars. The outer loop is used for the total number of rows, and the inner loop will print '*' based on the value of $I.
For $I=1 it will print one star '*'. For $I=2 it will print two stars '*'. For $I=3 it will print three stars '*'. For $I=4 it will print four stars '*'.
After every inner loop newline is printed using '<br>' tag.
Answer 3:
Output:
Explanation:
In the above program, we used nested loops. Here, we used 'I' instead of '$I' then printf() function will print 'I' instead of the value of $I.
Here, the pattern of 'I' will print on the webpage.
For $I=1 it will print one 'I'. For $I=2 it will print two 'I'. For $I=3 it will print three 'I'. For $I=4 it will print four 'I'.
After every inner loop newline is printed using '<br>' tag.
Answer 4:
Output:
Explanation:
In the above program, we used one outer-loop with a counter variable $I and two inner loops with counter variables $J and $K.
Iteration1: $I=1, The First Inner loop will print 1. The second Inner loop will not print anything. Iteration2: $I=2, The First Inner loop will print 12. The second Inner loop will print 1. Iteration3: $I=3, The First Inner loop will print 123. The second Inner loop will print 21. Iteration4: $I=4, The First Inner loop will print 1234. The second Inner loop will print 321.
After every Iteration newline is printed using '<br>' tag.
Answer 5:
Output:
Explanation:
In the above program, we used nested loops. Here, we wrote a program to print the pattern of stars. Here the outer loop is used for the total number of rows, and the inner loop will print the value of $K based on the value of $i.
For $I=4 it will print 4321. For $I=3 it will print 321. For $I=2 it will print 21. For $I=1 it will print 1.
After every inner loop newline is printed using '<br>' tag.
need an explanation for this answer? contact us directly to get an explanation for this answer