In interview, interviewer asked me to write program for star pattern. it was just to check my logic. in this post I am sharing this program.
Inner loop prints line wise and outer loop prints column wise.
Output of the above code will be
Inner loop prints line wise and outer loop prints column wise.
<?php
for($i = 0; $i < 10 ; $i++){
for($j = 0; $j <= $i ; $j++){
echo '*';
}
echo '<br/>';
}
?>
for($i = 0; $i < 10 ; $i++){
for($j = 0; $j <= $i ; $j++){
echo '*';
}
echo '<br/>';
}
?>
Output of the above code will be
*
**
***
****
*****
******
*******
********
*********
**********
For reverse star pattern click here
**
***
****
*****
******
*******
********
*********
**********
For reverse star pattern click here
No comments:
Post a Comment