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
We will be assuming here that our roots are of the form, in this case, r 1,2 = l + mi If we take the first root we'll find the following solution. x l + m i It i

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

A manager at the local Walmart needs to determine how many workers to hire to cover a 24-hour period. Each worker must work 9 consecutive hours but may only start work at the begin

Why is this correct/when is this the right idea

Question: (a) Explain the concepts of Inheritance and Polymorphism in Lingo programming. (b) Write short descriptions on parent scripts and child objects in Lingo object

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

Given a list of numbers, say my @input_numbers = (1, 1, 3, 5, 8, 13, 21, 34, 55, 89, 144); write a program map1.pl that will use the function map (a) to produce a list of

Write a java program for inserting a particular node.

One of the main strengths of the Perl programming language are its powerful text manipulation features. In this assignment, you will put them to  use for writing a Perl program tha

Implement the Prim's algorithm with array data structure as described in slide 12 of the file 04mst.ppt. Your program should have a runtime complexity of O(n2) and should be as eff