Shell script to print pyramid, Programming Languages

Shell Script to print pyramid

 

Program

 

#W.A.S.S. to create pyramid

 

echo -e "enter num:\c"

read n

j=1

k=1

 

while test $k -le $n          #this loop print as many * per line as the value of j

do

 

  j=$k

 

  while test $j -lt $n         #this loop print forward spaces in each line

  do

     echo -e " \c"            

     j=`expr $j + 1`

  done

 

  j=1

  while test $j -le $k        #this loop print as many * per line as the value of j

  do

     echo -e " * \c"

     j=`expr $j + 1`

  done

 

  echo " "

  k=`expr $k + 1`

 

done

 

Output

 

enter num:7

       *
      *  *
     *  *  *
    *  *  *  *
   *  *  *  *  *
  *  *  *  *  *  *
 *  *  *  *  *  *  *

      

 

 

Posted Date: 9/26/2012 4:37:23 AM | Location : United States







Related Discussions:- Shell script to print pyramid, Assignment Help, Ask Question on Shell script to print pyramid, Get Answer, Expert's Help, Shell script to print pyramid Discussions

Write discussion on Shell script to print pyramid
Your posts are moderated
Related Questions
This assignment will just focus on NookyKindle eBook orders.  That is, we'll be keeping track of the titles of eBooks and the number of orders for that particular eBook during a pa

Oracle 11G Reports We are troubleshooting the pagination of Oracle reports when printed from a browser. We need help determining the issue and correcting within the report ou

LALR Parser: Rule Table - Contains definitions of production rules within the grammar. Attributes: Count - Number of production rules in the table Child items:

1.  Develop HTML code to create a Web page with the red background and title "My First Page" in any other color. 2.  Develop an HTML document with details of your name, telephon

Need help with my assignment

I have a linux lab class that consist of 1 lab assignment per week for 5 weeks. It is an online virtual lab and is fairly easy, I just don''t have the time.

As an XML expert you are required to model a system for an online bookshop. After an interview with the shop manager you have the following information: The detail of th

Write a function called withdraw (in the file 'withdraw.m') that simulates withdrawing money from a bank account. The function takes a single input argument, a positive scaler doub


using UML 1- Identify primary classes 2- Scenario description 3- Class diagrams 4- Sequence diagrams