ga self study ko ug PHP right now. Total newbie ko about programming.
I would like to ask the experts for suggestions in how to make my code simpler.
The Challenge:
Write a program, in any free language, that prints to the terminal the lyrics to 99 Bottles of Beer | The lyrics to the song 99 Bottles of Beer
Here's my code:
Code:<?php $bottles=99; $oneless=98; do { echo "$bottles bottles of beer on the wall, $bottles bottles of beer. <br /> Take one down and pass it around, $oneless bottles of beer on the wall.<br /><br />"; $bottles--; $oneless--; } while ($bottles>2); echo "$bottles bottles of beer on the wall, $bottles bottles of beer. <br /> Take one down and pass it around, $oneless bottle of beer on the wall.<br /><br />"; $bottles--; echo "$bottles bottle of beer on the wall, $bottles bottle of beer. <br /> Take one down and pass it around, no more bottles of beer on the wall.<br /><br />"; echo "No more bottles of beer on the wall, no more bottles of beer. <br /> Go to the store and buy some more, 99 bottles of beer on the wall."; ?>
Do-while lang sa ako gigamit but naa moy masuggest nga better approach to make it simpler?
Murag bati kaayo tan-awon akong 3 echo statements sa last part of the code.![]()





Reply With Quote
