Q:

PHP Program to print Diamond Star Pattern

0
    *
   * *
  * * *
 * * * *
* * * * *
 * * * *
  * * *
   * *
    *

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php  
    for($i=0;$i<=5;$i++){  
    for($k=5;$k>=$i;$k--){  
    echo "&nbsp";  
    }  
    for($j=1;$j<=$i;$j++){  
        echo "* ";  
    }  
    echo "<br>";  
    }      
        for($i=4;$i>=1;$i--){  
        for($k=5;$k>=$i;$k--){  
        echo "&nbsp";  
    }  
    for($j=1;$j<=$i;$j++){  
    echo "* ";  
    }  
    echo "<br>";  
}  
?>

need an explanation for this answer? contact us directly to get an explanation for this answer
need an explanation for this answer? contact us directly to get an explanation for this answer

<?php  
    for($i=0;$i<=5;$i++){  
    for($k=5;$k>=$i;$k--){  
    echo "&nbsp";  
    }  
    for($j=1;$j<=$i;$j++){  
        echo "* ";  
    }  
    echo "<br>";  
    }      
        for($i=4;$i>=1;$i--){  
        for($k=5;$k>=$i;$k--){  
        echo "&nbsp";  
    }  
    for($j=1;$j<=$i;$j++){  
    echo "* ";  
    }  
    echo "<br>";  
}  
?>

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (2)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now