#diamond.pl
#!/bin/perl5
print "Enter the height of the diamond: ";
chomp($height=<STDIN>);
$temp=$height;
for($i=1;$i<=$height;$i++)
{
for($j=0;$j<$temp;$j++)
{
print " ";
}
$temp--;
for($k=0;$k<$i;$k++)
{
print "* ";
}
print "\n";
}
$temp=2;
for($i=$height-1;$i>=0;$i--)
{
for($j=0;$j<$temp;$j++)
{
print " ";
}
$temp++;
for($k=0;$k<$i;$k++)
{
print "* ";
}
print "\n";
}
Paid for writing
In case you like my writing and would like me to write for your website, then please leave a comment to any of my blog article, mentioning your Email Id and I will reply back. Thanks
Wednesday, January 28, 2009
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment