Monday 9 July 2012

pattern


Write a shell to generate the following
                *
                * *
                * * *
                * * * *
echo "Enter the number of Rows:"
read r
i=1
j=1
while [ $i -le $r ]
do
        j=1
        while [ $j -le $i ]
        do
        echo -e "* \c"
        j=`expr $j + 1`
        done
        echo -e "\n"
        i=`expr $i + 1`
done


--------------------------------------------------------------------------------------------------------------
                OUTPUT
Enter the number of Rows:
5
*

* *

* * *

* * * *

* * * * *

0 comments:

Post a Comment