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
The method should call getAllCities() and return the index of the City that has the shortest (euclidian) distance to the. longitude and latitude passed as parameters

Components of .NET Framework 3.5 .NET Framework Conceptual Overview Presents the .NET Structure and its elements. Installing the .NET Framework Provides information about .NET Stru

Hi how can I upload my hw to you experts?

Explain, in your own words, how web designers can deal with CSS conflict resolution. What is the order of precedence between the different types of CSS (inline, embedded and extern

Write a Prolog predicate  has_duplicates(L)  that is true if list  L  contains duplicated elements (that is at least 2 copies of an element). For instance: ?- has_duplicates([a,

Extensive programming platform .NET It is a new, simple, and comprehensive selection foundation. It is not a selection terminology, but it can handle several selection dialects.

.NET Windows Services But Enthusiasm has an amazing record of beginning overdue but finding up easily. This is real in situation of .NET too. Enthusiasm put their best men at

Short Arrays: Array = randi(10,1,randi(6,1,1)+4)-5 This command will generate an array which you should be able to evaluate by hand (and also have your code evaluate for te

Describe URL and hostname part? The hostname part of the URL should be a valid Internet hostname. It can also be an IP address like as 204.29.207.217 or 128.235.252.184. The

Write a function readPDBfile('filename') that will read the atoms for a protein stored in a PDB file, whose name is provided as an input to the function (note that this name should