Posts

Showing posts from September, 2019

Write Below Pattern Using for loop Coding & Print Pattern in Php.

Output of Print Pattern * ** *** **** ***** ****** ***** **** *** ** * Php Print Pattern Code in Below   <?php  for($i=0;$i<=6;$i++) {    // echo $i;    for($j=0;$j <$i;$j++)    { echo "*";     } echo "<br>";  }  for($i=4;$i >=0; $i--) { for($j=0;$j <= $i;$j++)     { echo "*";     }     echo "<br>";  } ?> This program is print the follows pattern using the for loop use print the two main for loop and two are sub for loop and this logic is we create the first loop is started 0 to 6 and other is start 4 to 0 so it will print the above pattern.
***** ***** ***** ***** ***** <?php  for ($i=1; $i <=5 ; $i++) {  # code.e.. for($j=0;$j <5; $j++){   echo "*";   } echo "<br>"; } ?> This php script is used to print the above pattern it will like one box. in this output we will used the for loop.   This code we used two different for loop .one loop is start form  1  and go to 5 all time it will increment.   Second loop is call inside the main loop it will also start with 0 and goes to 5  after we print the inside loop * only .    last we used to break the link using "<br>" Thanks Vips the dev
* *  * *  *  * *  *  *  * *  *  *  *  * *  *  *  *  *  * *  *  *  *  * *  *  *  * *  *  * *  * * <?php for ($i=1; $i <=6; $i++) {  # code... echo "*"; for ($j=1; $j <$i ; $j++) {  # code... echo "*"; } echo "<br>"; } for ($i=5;$i >=1; $i--) {  # code... echo "*"; for ($j=1; $j < $i; $j++) {  # code... echo "*"; } echo "<br>"; }  ?> This out put is print pyramid In PHP .This code is using for loop to print out put it print good output. in this program main two for loop are there and inside one loop one more sub for loop are there.  First for loop is print upper first 6 line, as * and i will work as start to 1 and goes to 6 and increment to as 6. inside sub for loop is print start form 1 and goes to last as $i value for main loop also it increment. and ...