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
Need help with my assignment

how do u define a letter in python "NameError: name ''r'' is not defined"


Lazytown Constabulary are concerned that young people in the town are unaware of the sorts of crime that they might encounter in their daily lives and are concerned that they may b

The following function calls supposedly write a single new-line character, but some are incorrect. Identify which calls don't work and explain why.     printf("%c", '\n');

The ATM will simulate a real world automated teller machine that supports safe access to accounts from multiple concurrent clients.

What are Relative URLS ? When a web browser reads an HTML document, it has a great deal of information about the document. This includes the protocol used to retrieve the docu

Problem: (i) Define Remote Procedure Call (RPC). (ii) Explain with diagram how RPC works? (iii) A remote procedure is uniquely defined by (a) Program number. (b)

For this assignment you will read a file expression.txt and create an expression tree. The expression will be a valid infix expression with the all the necessary parentheses so tha

Implement a two-dimensional table in Prolog. Your program will contain: 1.  An insert_entry predicate that takes a table, row, column and an entry and inserts the entry at the g